摘要: class Solution { public: ListNode* reverseKGroup(ListNode* head, int k) { ListNode *cur = head; for (int i = 0; i < k; ++i) { if (!cur) return head; c 阅读全文
posted @ 2017-02-10 22:42 王坤1993 阅读(105) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: ListNode* swapPairs(ListNode* head) { if (!head || !head->next) return head; ListNode *t = head->next; head->next = swapPairs 阅读全文
posted @ 2017-02-10 22:38 王坤1993 阅读(132) 评论(0) 推荐(0) 编辑
摘要: struct cmp { bool operator () (ListNode *a, ListNode *b) { return a->val > b->val; } }; class Solution { public: ListNode *mergeKLists(vector<ListNode 阅读全文
posted @ 2017-02-10 22:35 王坤1993 阅读(130) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector<string> generateParenthesis(int n) { set<string> t; if (n == 0) t.insert(""); else { vector<string> pre = generatePare 阅读全文
posted @ 2017-02-10 22:32 王坤1993 阅读(142) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { if (!l1) return l2; if (!l2) return l1; if (l1->val < l2->val) { l1->ne 阅读全文
posted @ 2017-02-10 22:29 王坤1993 阅读(108) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: bool isValid(string s) { stack<char> parentheses; for (int i = 0; i < s.size(); ++i) { if (s[i] == '(' || s[i] == '[' || s[i] 阅读全文
posted @ 2017-02-10 22:27 王坤1993 阅读(130) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { if (!head->next) return NULL; ListNode *pre = head, *cur = head; for (int 阅读全文
posted @ 2017-02-10 22:25 王坤1993 阅读(99) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector<vector<int> > fourSum(vector<int> &nums, int target) { set<vector<int> > res; sort(nums.begin(), nums.end()); for (int 阅读全文
posted @ 2017-02-10 00:01 王坤1993 阅读(138) 评论(0) 推荐(0) 编辑