• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
村雨sup
自己选的路,跪着也要走完 XD
博客园    首页    新随笔    联系   管理    订阅  订阅
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 阅读(111) 评论(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)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3