摘要:
``` class Solution { public: int evalRPN(vector &tokens) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance w 阅读全文
posted @ 2019-04-10 10:49
JohnRed
阅读(74)
评论(0)
推荐(0)
摘要:
``` class Solution { public: int maxPoints(vector& points) { int res = 0; for (int i = 0; i , int> m; int duplicate = 1; for (int j = i + 1; j second + dupl... 阅读全文
posted @ 2019-04-10 10:48
JohnRed
阅读(66)
评论(0)
推荐(0)
摘要:
``` class Solution { public: ListNode* sortList(ListNode* head) { if (!head || !head->next) return head; ListNode *slow = head, *fast = head, *pre = head; while (fast && fa... 阅读全文
posted @ 2019-04-10 10:45
JohnRed
阅读(104)
评论(0)
推荐(0)
摘要:
``` class Solution { public: ListNode* insertionSortList(ListNode* head) { ListNode *dummy = new ListNode(-1), *cur = dummy; while (head) { ListNode *t = head->next; ... 阅读全文
posted @ 2019-04-10 10:39
JohnRed
阅读(66)
评论(0)
推荐(0)
摘要:
``` class Solution { public: vector postorderTraversal(TreeNode* root) { if (!root) return {}; vector res; stack s{{root}}; TreeNode *head = root; while (!s... 阅读全文
posted @ 2019-04-10 10:38
JohnRed
阅读(64)
评论(0)
推荐(0)
摘要:
``` class Solution { public: vector preorderTraversal(TreeNode* root) { if (!root) return {}; vector res; stack s{{root}}; while (!s.empty()) { TreeNode... 阅读全文
posted @ 2019-04-10 10:35
JohnRed
阅读(75)
评论(0)
推荐(0)
摘要:
``` class Solution { public: void reorderList(ListNode *head) { if (!head || !head->next || !head->next->next) return; stack st; ListNode *cur = head; while (cur) {... 阅读全文
posted @ 2019-04-10 10:32
JohnRed
阅读(126)
评论(0)
推荐(0)
摘要:
```
class Solution {
public: ListNode *detectCycle(ListNode *head) { ListNode *slow = head, *fast = head; while (fast && fast->next) { slow = slow->next; fa... 阅读全文
posted @ 2019-04-10 10:29
JohnRed
阅读(54)
评论(0)
推荐(0)
摘要:
```
class Solution {
public: bool hasCycle(ListNode *head) { ListNode *slow = head, *fast = head; while (fast && fast->next) { slow = slow->next; fast = fas... 阅读全文
posted @ 2019-04-10 10:28
JohnRed
阅读(72)
评论(0)
推荐(0)
摘要:
``` class Solution { vector midres; vector res; vector *dp; public: vector wordBreak(string s, unordered_set &dict) { int len = s.length(); dp ... 阅读全文
posted @ 2019-04-10 10:27
JohnRed
阅读(89)
评论(0)
推荐(0)

浙公网安备 33010602011771号