Skip to content

Commit 1bf882d

Browse files
Merge pull request #82 from hiveryeah/master
第一周作业#23
2 parents 0249792 + c7d9fed commit 1bf882d

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

Week_01/id_23/LeetCode_26_23

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int removeDuplicates(int[] nums) {
3+
if (nums.length == 0 ) return 0;
4+
int i = 0;
5+
for(int j=1; j<nums.length; j++){
6+
if (nums[j] != nums[i]){
7+
nums[i+1] = nums[j];
8+
i++;
9+
}
10+
}
11+
return i+1;
12+
}
13+
}

Week_01/id_23/LeetCode_88_23

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public void merge(int[] nums1, int m, int[] nums2, int n) {
3+
if (nums1.length == 0 || nums2.length == 0 ) return;
4+
5+
int p = m-- + n-- - 1;
6+
while (m >= 0 && n >= 0) {
7+
nums1[p--] = nums1[m] > nums2[n] ? nums1[m--] : nums2[n--];
8+
}
9+
10+
while (n >= 0) {
11+
nums1[p--] = nums2[n--];
12+
}
13+
}
14+
}

Week_01/id_23/NOTE.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
# 学习笔记
1+
# 学习笔记
2+
###本周总结
3+
之前在算法与数据结构的面试和任务上栽过很多次跟头,但每次痛心疾首之后,立过的flag继续随着时间的调用,一次次入栈…………变成了压箱底儿的任务。我越来越坚信,如果有个事情来了,你却没有勇敢地去解决掉,它一定会再来。生活真是这样,它会一次次地让你去做这个功课,知道你学会为止。生活大课适用,同理算法课也适用此公式。
4+
5+
#### 关于Big O
6+
数据结构和算法本身解决的是“快”和“省”的问题。大O表示的是算法运行时间的增速!
7+
8+
极客时间版权所有: https://time.geekbang.org/column/article/40036
9+
#### 关于递归 Recursion
10+
“如果使用循环,程序地性能可能更高;如果适用递归,程序可能更容易理解。如何选择要看什么对你来说更重要” --Leigh Caldwell
11+
递归套路模板 1. Recursion terminator2. Process logic 3.Drill down 4.Reverse the current level status if needed
665 KB
Loading

0 commit comments

Comments
 (0)