活跃农民
- 积分
- 307
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2014-4-28
- 最后登录
- 1970-1-1
|
最近一直刷题,但是可能就不坚持每天往地里更新了,隔几天更新一次。。currently40/178
Climbing Stairs
| same as fibonacci number: 1) recursive ->2) dp ->3)use three variable to save space
|
| Implement strStr()
| brute Force.两层循环。
| 需要找到的needle如果为空,则返回0. 若haystack为空活着小于needle长度返回-1。 确定何时退出。break/continue 区别。
| Valid Parentheses
| push to stack when ({[ , pop and check when )}]
| input something random at first, in case check ] … at first
| Set Matrix Zeroes
| use row 0 and column 0 to store the result. if(matrix[i][j] == 0) then matrix[i][0] = 0, matrix[0][j] = 0
| rows 0 and columns 0 need to be a separate case. Find if they have 0 or not. Assign value 0 later
| Find Minimum in Rotated Sorted Array ||
| if a[left] > a[right], it is ordered, return a[left]. if a[left] < a[right], find whether left or right part is organized(middle).
|
|
Searched in rotated array
| binary search. only half is sorted, the other half is not. so need to decide it is in the sorted or unsorted side
| the condition of stopping while loop. what idx should be left or right
| Unique Paths
| have a m*n matrix to store the number of unique paths. Dynamic programming
| assign value 1 to 0 array and 0 column.
| Unique Paths II
| just compute to the given matrix, if it is 1. then dp[j] should be 0
| the 0 row should not be 1 any more. also it should be dp[j] = dp[j-1] if the given matrix at this point is 1
|
|
|