
LeetCode
Left翼
IT本科生一枚
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[LeetCode] Longest Valid Parentheses 解题报告
原题链接Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()"原创 2015-01-31 20:45:53 · 380 阅读 · 0 评论 -
逆序对问题的求解 Solution of Inverse-Pairs Problem
时间复杂度最低的方法是,修改归并排序(Merge Sort),在排序同时对逆序对计数。时间复杂度为 O(nlogn)O(n\log{n})。代码:.....原创 2015-07-28 19:15:33 · 752 阅读 · 0 评论 -
删除链表中重复的结点 Delete duplicated nodes in linked list
在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。例如,链表 1->2->3->3->4->4->5 处理后为 1->2->5 题解这题看似很简单,但是务必考虑如下情形:........ 另外,遍历链表千万不要为了简洁写成for循环!我因为这个出了bug,看了很久才看出来原创 2015-07-29 21:15:13 · 656 阅读 · 0 评论 -
leetcode - 字符串转换成数字(String to Integer)atoi
https://leetcode.com/problems/string-to-integer-atoi/把字符串转换成数字,即实现atoi函数。坑多慎重。class Solution {public: int myAtoi(string str) { int len = str.length(); int index = 0; while原创 2015-08-17 14:39:17 · 543 阅读 · 0 评论