摘要:
class Solution { public: ListNode* reverseKGroup(ListNode* head, int k) { ListNode *cur = head; for (int i = 0; i < k; ++i) { if (!cur) return head; c 阅读全文
摘要:
class Solution { public: ListNode* swapPairs(ListNode* head) { if (!head || !head->next) return head; ListNode *t = head->next; head->next = swapPairs 阅读全文
摘要:
struct cmp { bool operator () (ListNode *a, ListNode *b) { return a->val > b->val; } }; class Solution { public: ListNode *mergeKLists(vector<ListNode 阅读全文
摘要:
class Solution { public: vector<string> generateParenthesis(int n) { set<string> t; if (n == 0) t.insert(""); else { vector<string> pre = generatePare 阅读全文
摘要:
class Solution { public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { if (!l1) return l2; if (!l2) return l1; if (l1->val < l2->val) { l1->ne 阅读全文
摘要:
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] 阅读全文
摘要:
class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { if (!head->next) return NULL; ListNode *pre = head, *cur = head; for (int 阅读全文
摘要:
class Solution { public: vector<vector<int> > fourSum(vector<int> &nums, int target) { set<vector<int> > res; sort(nums.begin(), nums.end()); for (int 阅读全文