• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
yanqi
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理
上一页 1 2 3 4 5 下一页

2015年11月18日

LeetCode() Search for a Range
摘要: class Solution {public: vector searchRange(vector& nums, int target) { vector res; vector xxx; xxx.push_back(-1); xxx.p... 阅读全文
posted @ 2015-11-18 13:46 yanqi 阅读(114) 评论(0) 推荐(0)
 
LeetCode() Search a 2D MatrixII
摘要: 一开始的超时思路int row=a.size(),col=a[0].size(); for(int i=0;i target && a[i][0] target) low = mid-1; else ... 阅读全文
posted @ 2015-11-18 10:40 yanqi 阅读(109) 评论(0) 推荐(0)
 
 

2015年11月17日

LeetCode() Remove Duplicates from Sorted Array II
摘要: 我的思路:先判断是不是有两个相等的,如果有,从2个之后查找还有几个相同的,start计数。class Solution {public: int removeDuplicates(vector& nums) { if(nums.size() == 0) re... 阅读全文
posted @ 2015-11-17 22:16 yanqi 阅读(156) 评论(0) 推荐(0)
 
LeetCode() Rotate Image
摘要: 先改成对角线对换,然后再上下对换,如下所示1,2, 3, 45, 6, 7, 89, 10,11,1213,14,15,1616,12, 8, 415,11, 7, 314,10, 6, 213, 9, 5, 113, 9, 5, 114,10, 6, 215,11, 7, 316,12, 8, 4... 阅读全文
posted @ 2015-11-17 21:52 yanqi 阅读(112) 评论(0) 推荐(0)
 
 

2015年11月16日

LeetCode() Sort Colors
摘要: 一个数组里有0,1,2三种数,排列非常牛逼的思路!!class Solution {public: void sortColors(vector& nums) { int i=-1,j=-1,k=-1; for(int p=0;p& nums) { ... 阅读全文
posted @ 2015-11-16 22:10 yanqi 阅读(129) 评论(0) 推荐(0)
 
LeetCode() Spiral Matrix
摘要: 顺时针打印二维数组,以前在牛客网上做过,不过还是忘了 int n,m; vector > v; bool judge(int i,int j) { return i>=0 && i=0 && j printMatrix(vector > matrix) { ... 阅读全文
posted @ 2015-11-16 15:39 yanqi 阅读(174) 评论(0) 推荐(0)
 
 

2015年11月15日

LeetCode() Find Minimum in Rotated Sorted Array
摘要: 不明白这个思路class Solution {public: int findMin(vector& num) { int size = num.size() - 1; int l = 0; int r = size; while(l n... 阅读全文
posted @ 2015-11-15 21:09 yanqi 阅读(108) 评论(0) 推荐(0)
 
LeetCode(169)Majority Element and Majority Element II
摘要: 一个数组里有一个数重复了n/2多次,找到思路:既然这个数重复了一半以上的长度,那么排序后,必然占据了 a[n/2]这个位置。class Solution {public: int majorityElement(vector& nums) { sort(nums.begin(),... 阅读全文
posted @ 2015-11-15 14:31 yanqi 阅读(122) 评论(0) 推荐(0)
 
 

2015年11月14日

LeetCode(88) Merge Sorted Array
摘要: Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.非常好的思路:从两个数组的最后开始比较,直接放在了最后,因为已经知道了两个数组的长度,所以最后的坐标是 m+n-1 而每次比较后 ... 阅读全文
posted @ 2015-11-14 16:19 yanqi 阅读(94) 评论(0) 推荐(0)
 
LeetCode(283) Move Zeroes
摘要: class Solution {public: void moveZeroes(vector& nums) { int len=nums.size(); int start=0; for(int i=0;i<len;++i) { ... 阅读全文
posted @ 2015-11-14 16:11 yanqi 阅读(98) 评论(0) 推荐(0)
 
 
上一页 1 2 3 4 5 下一页

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3