2014年3月1日

3-1

摘要: 不知不觉3月1日了,离实习的时间越来越近,论文还没有开搞,略急啊……刷了4道题,星期天休息~~Valid Number调了2小时不通,打算放弃来着,文清说了一句“你就这么放弃了?”,又坐回来重新调,结果20分钟调好了……羞愧啊……这题需要考虑的东西好多,以后拿来锻炼思维缜密度。Add Binary就是熟练下stringClimbing Stairs用了3个int的常驻内存空间,不知道有没有用的更少的算法?Merge Sorted Array昨天晚上的mergesort真是没白看,不申请多余内存空间,尽量减少数据移动次数。难得天这么蓝,好想出去兜风啊~~老老实实看书明天再疯吧! 阅读全文

posted @ 2014-03-01 15:26 pengyu2003 阅读(100) 评论(0) 推荐(0)

Merge Sorted Array

摘要: Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal tom+n) to hold additional elements from B. The number of elements initialized in A and B aremandnrespectively.非常水题。不过需要注意后面的补全。练习过mergesort()都不会多申请内存 阅读全文

posted @ 2014-03-01 15:14 pengyu2003 阅读(164) 评论(0) 推荐(0)

Climbing Stairs

摘要: You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?动态规划大水题。类似斐波那契额数列。class Solution {public: int climbStairs(int n) { if(n == 0 || n == 1|| n == 2)return n; int a =... 阅读全文

posted @ 2014-03-01 14:50 pengyu2003 阅读(115) 评论(0) 推荐(0)

Add Binary

摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".很简单的题,代码写麻烦了。注意string加的顺序。class Solution {public: string addBinary(string a, string b) { int la = a.length()-1; int lb = b.length()-1; string re; int flag = 0; ... 阅读全文

posted @ 2014-03-01 14:33 pengyu2003 阅读(152) 评论(0) 推荐(0)

Valid Number

摘要: alidate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing 阅读全文

posted @ 2014-03-01 14:08 pengyu2003 阅读(205) 评论(0) 推荐(0)

导航