• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
村雨sup
自己选的路,跪着也要走完 XD
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 42 下一页
2018年9月18日
Leetcode 33
摘要: //这题真的很有思维难度啊,前前后后弄了2个小时才写完。//一定要首先将连续的一段找出来,如果target在里面就在里面找,如果不在连续段里就在另一部分找。//如果后面二分到都是连续段也是没事了,我们找的另一段也是连续的没有问题的。//最后面de的两个bug是判断nums[left] & nums, int target) { int left = 0; int ... 阅读全文
posted @ 2018-09-18 17:02 村雨sup 阅读(150) 评论(0) 推荐(0)
Leetcode 34
摘要: //二分查找后,向两边扩展,二分错了两次,现在是对的。//还有就是vector可以用{}直接赋值很棒class Solution { public: vector searchRange(vector& nums, int target) { int left = 0; int right = nums.size()-1; int mid ... 阅读全文
posted @ 2018-09-18 14:52 村雨sup 阅读(320) 评论(0) 推荐(0)
Leetcode 35
摘要: //在数组最后插入INT_MAX是个好方法class Solution { public: int searchInsert(vector& nums, int target) { nums.push_back(INT_MAX); for(int i=0;i < nums.size();i++){ if(target <= nums... 阅读全文
posted @ 2018-09-18 14:10 村雨sup 阅读(101) 评论(0) 推荐(0)
Leetcode 28
摘要: //有个神奇的东西class Solution { public: int strStr(string haystack, string needle) { if(needle == "")return 0; int lenn = haystack.size()-needle.size(); //如果不用这个直接把haystack.size()-needl... 阅读全文
posted @ 2018-09-18 09:56 村雨sup 阅读(110) 评论(0) 推荐(0)
Leetcode 27
摘要: easy 阅读全文
posted @ 2018-09-18 09:05 村雨sup 阅读(77) 评论(0) 推荐(0)
Leetcode 26
摘要: class Solution { public: int removeDuplicates(vector& nums) { int res = 0; nums.push_back(INT_MAX); //注意末尾的补位 for(int i=0;i < nums.size()-1;i++){ if(nums[i] !... 阅读全文
posted @ 2018-09-18 08:47 村雨sup 阅读(67) 评论(0) 推荐(0)
2018年9月17日
Leetcode 24
摘要: //需要注意的就是只用一个pre就能完成交换,一次AC,happy,已经忘记了第一次写链表时候的痛苦,所以说算法没难的,只不过练的欠火候。/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val... 阅读全文
posted @ 2018-09-17 17:02 村雨sup 阅读(131) 评论(0) 推荐(0)
2018年9月12日
Leetcode 21
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *///还可以简单的一遍AC class Solution { public: ... 阅读全文
posted @ 2018-09-12 11:39 村雨sup 阅读(104) 评论(0) 推荐(0)
2018年9月11日
Leetcode 20
摘要: 别人写的:差距啊! 阅读全文
posted @ 2018-09-11 17:25 村雨sup 阅读(117) 评论(0) 推荐(0)
2018年9月10日
Leetcode 19
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *///一开始发现头结点不好删啊,然后加了一个前置节点就ok了 class Solut... 阅读全文
posted @ 2018-09-10 17:00 村雨sup 阅读(103) 评论(0) 推荐(0)
上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 42 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3