摘要:
隔了好久好久好久好久开始做题~要坚持下去鸭! Num 67 二进制求和 以后不贴英文名字了 class Solution { public: string addBinary(string a, string b) { int lena=a.length(); int lenb=b.length() 阅读全文
摘要:
隔了好久好久好久好久开始做题~要坚持下去鸭! Num 67 二进制求和 以后不贴英文名字了 class Solution { public: string addBinary(string a, string b) { int lena=a.length(); int lenb=b.length() 阅读全文
摘要:
Num 169 先码,回头再说,摩尔算法。。。 tle了 class Solution { public: int majorityElement(vector<int>& nums) { int len=nums.capacity(); int count=1; int now=nums[0]; 阅读全文
摘要:
Num 125 验证回文串 Valid Palindrome 非常有收货的一道题嘻嘻嘻,本来是考试期间划水挑的题,坑点有点多 第一个是注意对temp1和temp2中途更新的判断 第二个是字符串频繁的作为参数出现,一次又一次的出现会爆内存,使用const string &s这样不复制(奇怪len等于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 阅读全文
摘要:
跳题,不熟悉的留到周末再做。 保持冷静,不信画饼。 num 100 相同的树 Same Tree 做法可能不是特别简洁,注意一下。最后判断完子树以后,要确定根的数值是一样的 然后在isleaf的判定先要确定NULL /** * Definition for a binary tree node. * 阅读全文
摘要:
Num 38 报数 Count and Say 题意读起来比较费劲。。看懂了题还是不难的 注意最后的长度是sz的长度,开始写错写的len 在下次计算的时候len要更新下 说明 直接让char和int进行转换的过程中,int a=1,转成char是ascii为1的一个东西,要a+48,如果是char 阅读全文
摘要:
今天是纠结要不要新买手机的一天QAQ想了想还是算了吧,等自己赚钱买,加油 Num 70 爬楼梯 Climbing Stairs class Solution { public: int climbStairs(int n) { int a[10000]; a[1]=1; a[2]=2; for(in 阅读全文
摘要:
还没有背单词,头晕脑胀 Num 66 加一 Plus One 注意就是进位的时候最后一位,为了省两句代码,那几个语句顺序写反覆盖的乱七八糟 vector头部插入(a.begin(),被插入的数) 如果是(a.begin()+2,被插入的数字) 是指在序号为2的前面插入(有空试一下) class So 阅读全文
摘要:
突发奇想&胡思乱想的一天 银行家算法证明错了并挂在黑板上的可怜希希 Num 53 最大子序和 Maximum Subarray O(n)的算法实现了,分治法有空补 class Solution { public: int maxSubArray(vector<int>& nums) { int a[ 阅读全文
摘要:
刷题成习惯以后感觉挺好的 Num 27 移除元素 Remove Element 跟那个排序去掉相同的一样,len标记然后新的不重复的直接放到len class Solution { public: int removeElement(vector<int>& nums, int val) { int 阅读全文
|