上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 32 下一页
摘要: ``` class Solution { public: int findPeakElement(vector& nums) { for (int i = 1; i 阅读全文
posted @ 2019-04-10 11:05 JohnRed 阅读(91) 评论(0) 推荐(0)
摘要: ``` class Solution { public: bool isOneEditDistance(string s, string t) { if (s.size() = 2) return false; else if (diff == 1) { for (int i = 0; i 阅读全文
posted @ 2019-04-10 11:04 JohnRed 阅读(124) 评论(0) 推荐(0)
摘要: ``` class Solution { public: ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { if (!headA || !headB) return NULL; ListNode *a = headA, *b = headB; while (a ... 阅读全文
posted @ 2019-04-10 11:02 JohnRed 阅读(91) 评论(0) 推荐(0)
摘要: ``` class Solution { public: int lengthOfLongestSubstringTwoDistinct(string s) { int res = 0, left = 0; unordered_map m; for (int i = 0; i 2) { if (--m[s[l... 阅读全文
posted @ 2019-04-10 11:01 JohnRed 阅读(69) 评论(0) 推荐(0)
摘要: ``` // Recursion class Solution { public: TreeNode *upsideDownBinaryTree(TreeNode *root) { if (!root || !root->left) return root; TreeNode *l = root->left, *r = root->right; ... 阅读全文
posted @ 2019-04-10 10:59 JohnRed 阅读(100) 评论(0) 推荐(0)
摘要: ``` class MinStack { public: /** initialize your data structure here. */ MinStack() {} void push(int x) { s1.push(x); if (s2.empty() || x s1, s2; }; ``` 阅读全文
posted @ 2019-04-10 10:57 JohnRed 阅读(77) 评论(0) 推荐(0)
摘要: ``` class Solution { public: int findMin(vector &nums) { if (nums.empty()) return 0; int left = 0, right = nums.size() - 1, res = nums[0]; while (left nums[mid]) { ... 阅读全文
posted @ 2019-04-10 10:56 JohnRed 阅读(53) 评论(0) 推荐(0)
摘要: ``` class Solution { public: int findMin(vector &num) { int left = 0, right = num.size() 1; if (num[left] num[right]) { while (left != (right 1)) { in 阅读全文
posted @ 2019-04-10 10:55 JohnRed 阅读(66) 评论(0) 推荐(0)
摘要: ``` class Solution { public: int maxProduct(vector& nums) { if (nums.empty()) return 0; int res = nums[0], mn = nums[0], mx = nums[0]; for (int i = 1; 阅读全文
posted @ 2019-04-10 10:53 JohnRed 阅读(64) 评论(0) 推荐(0)
摘要: ``` class Solution { public: /** * @param s : A string * @return : A string */ string reverseWords(string s) { istringstream is(s); is >> s; string t; ... 阅读全文
posted @ 2019-04-10 10:50 JohnRed 阅读(87) 评论(0) 推荐(0)
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 32 下一页