ltx_zero

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 8 9 10 11 12 13 下一页

2019年7月3日

摘要: 隔了好久好久好久好久开始做题~要坚持下去鸭! Num 67 二进制求和 以后不贴英文名字了 class Solution { public: string addBinary(string a, string b) { int lena=a.length(); int lenb=b.length() 阅读全文
posted @ 2019-07-03 18:59 ltx_zero 阅读(177) 评论(0) 推荐(0) 编辑

2019年4月23日

摘要: Num 169 先码,回头再说,摩尔算法。。。 tle了 class Solution { public: int majorityElement(vector<int>& nums) { int len=nums.capacity(); int count=1; int now=nums[0]; 阅读全文
posted @ 2019-04-23 00:30 ltx_zero 阅读(111) 评论(0) 推荐(0) 编辑

2019年4月21日

摘要: Num 125 验证回文串 Valid Palindrome 非常有收货的一道题嘻嘻嘻,本来是考试期间划水挑的题,坑点有点多 第一个是注意对temp1和temp2中途更新的判断 第二个是字符串频繁的作为参数出现,一次又一次的出现会爆内存,使用const string &s这样不复制(奇怪len等于0 阅读全文
posted @ 2019-04-21 23:52 ltx_zero 阅读(134) 评论(0) 推荐(0) 编辑

摘要: Num 121 买卖股票的最佳时期 Best Time to Buy and Sell Stock class Solution { public: int maxProfit(vector<int>& prices) { int len=prices.capacity(); if(prices.c 阅读全文
posted @ 2019-04-21 00:46 ltx_zero 阅读(177) 评论(0) 推荐(0) 编辑

2019年4月19日

摘要: 跳题,不熟悉的留到周末再做。 保持冷静,不信画饼。 num 100 相同的树 Same Tree 做法可能不是特别简洁,注意一下。最后判断完子树以后,要确定根的数值是一样的 然后在isleaf的判定先要确定NULL /** * Definition for a binary tree node. * 阅读全文
posted @ 2019-04-19 23:39 ltx_zero 阅读(150) 评论(0) 推荐(0) 编辑

2019年4月18日

摘要: Num 38 报数 Count and Say 题意读起来比较费劲。。看懂了题还是不难的 注意最后的长度是sz的长度,开始写错写的len 在下次计算的时候len要更新下 说明 直接让char和int进行转换的过程中,int a=1,转成char是ascii为1的一个东西,要a+48,如果是char 阅读全文
posted @ 2019-04-18 08:19 ltx_zero 阅读(170) 评论(0) 推荐(0) 编辑

2019年4月17日

摘要: 今天是纠结要不要新买手机的一天QAQ想了想还是算了吧,等自己赚钱买,加油 Num 70 爬楼梯 Climbing Stairs class Solution { public: int climbStairs(int n) { int a[10000]; a[1]=1; a[2]=2; for(in 阅读全文
posted @ 2019-04-17 22:16 ltx_zero 阅读(106) 评论(0) 推荐(0) 编辑

2019年4月16日

摘要: 还没有背单词,头晕脑胀 Num 66 加一 Plus One 注意就是进位的时候最后一位,为了省两句代码,那几个语句顺序写反覆盖的乱七八糟 vector头部插入(a.begin(),被插入的数) 如果是(a.begin()+2,被插入的数字) 是指在序号为2的前面插入(有空试一下) class So 阅读全文
posted @ 2019-04-16 22:44 ltx_zero 阅读(128) 评论(0) 推荐(0) 编辑

2019年4月15日

摘要: 突发奇想&胡思乱想的一天 银行家算法证明错了并挂在黑板上的可怜希希 Num 53 最大子序和 Maximum Subarray O(n)的算法实现了,分治法有空补 class Solution { public: int maxSubArray(vector<int>& nums) { int a[ 阅读全文
posted @ 2019-04-15 21:30 ltx_zero 阅读(99) 评论(0) 推荐(0) 编辑

2019年4月14日

摘要: 刷题成习惯以后感觉挺好的 Num 27 移除元素 Remove Element 跟那个排序去掉相同的一样,len标记然后新的不重复的直接放到len class Solution { public: int removeElement(vector<int>& nums, int val) { int 阅读全文
posted @ 2019-04-14 14:56 ltx_zero 阅读(140) 评论(0) 推荐(0) 编辑

上一页 1 ··· 8 9 10 11 12 13 下一页