摘要: class Solution { public: int searchInsert(vector& nums, int target) { if (nums.back() 阅读全文
posted @ 2019-04-08 21:07 JohnRed 阅读(68) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector searchRange(vector& nums, int target) { vector res(2, 1); int left = 0, right = nums.size() 1; while (left 阅读全文
posted @ 2019-04-08 21:05 JohnRed 阅读(99) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int search(vector& nums, int target) { int left = 0, right = nums.size() - 1; while (left = target) left = mid + 1; else right = mid - ... 阅读全文
posted @ 2019-04-08 20:58 JohnRed 阅读(66) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int longestValidParentheses(string s) { int result=0; s=')'+s; vector dp(s.length(),0); for(int i=1;i 阅读全文
posted @ 2019-04-08 20:56 JohnRed 阅读(94) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: void nextPermutation(vector& nums) {int n = nums.size(), i = n 2, j = n 1; while (i = 0 && nums[i] = nums[i + 1]) i; if (i = 阅读全文
posted @ 2019-04-08 20:52 JohnRed 阅读(70) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector findSubstring(string s, vector& words) { vector res; if (s.empty() || words.empty()) return res; int n = words.size(), m = words[0].size... 阅读全文
posted @ 2019-04-08 20:50 JohnRed 阅读(71) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int divide(int dividend, int divisor) { if (divisor == 0 || (dividend == INT_MIN && divisor == 1)) return INT_MAX; long l 阅读全文
posted @ 2019-04-08 19:57 JohnRed 阅读(57) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int removeElement(vector& nums, int val) { int res = 0; for (int i = 0; i 阅读全文
posted @ 2019-04-08 19:53 JohnRed 阅读(55) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int removeDuplicates(vector& nums) { if (nums.empty()) return 0; int pre = 0, cur = 0, n = nums.size(); while (cur 阅读全文
posted @ 2019-04-08 19:52 JohnRed 阅读(59) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: ListNode* reverseKGroup(ListNode* head, int k) { if (!head || k == 1) return head; ListNode *dummy = new ListNode(-1), *pre = dummy, *cur = head; ... 阅读全文
posted @ 2019-04-08 19:51 JohnRed 阅读(66) 评论(0) 推荐(0) 编辑