From 340d7eb32008b2812d8fb7d1982b9a7fe91cbb0c Mon Sep 17 00:00:00 2001 From: CyC2018 <1029579233@qq.com> Date: Tue, 10 Apr 2018 17:23:01 +0800 Subject: [PATCH] auto commit --- notes/HTTP.md | 2 +- notes/Java 基础.md | 8 ++++---- notes/剑指 offer 题解.md | 21 ++++++++++----------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/notes/HTTP.md b/notes/HTTP.md index 82c4a36a..cf6ae204 100644 --- a/notes/HTTP.md +++ b/notes/HTTP.md @@ -828,7 +828,7 @@ HTTP/1.1 的解析是基于文本的,而 HTTP/2.0 采用二进制格式。 # 参考资料 -- 上野宣. 图解 HTTP[M]. Ren min you dian chu ban she, 2014. +- 上野宣. 图解 HTTP[M]. 人民邮电出版社, 2014. - [MDN : HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP) - [Are http:// and www really necessary?](https://www.webdancers.com/are-http-and-www-necesary/) - [HTTP (HyperText Transfer Protocol)](https://www.ntu.edu.sg/home/ehchua/programming/webprogramming/HTTP_Basics.html) diff --git a/notes/Java 基础.md b/notes/Java 基础.md index 2d7d0a20..bc863655 100644 --- a/notes/Java 基础.md +++ b/notes/Java 基础.md @@ -12,7 +12,7 @@ * [访问权限](#访问权限) * [抽象类与接口](#抽象类与接口) * [super](#super) - * [重载与重写](#重载与重写) + * [覆盖与重载](#覆盖与重载) * [五、String](#五string) * [String, StringBuffer and StringBuilder](#string,-stringbuffer-and-stringbuilder) * [String 不可变的原因](#string-不可变的原因) @@ -706,11 +706,11 @@ SuperExtendExample.func() > [Using the Keyword super](https://docs.oracle.com/javase/tutorial/java/IandI/super.html) -## 重载与重写 +## 覆盖与重载 -- 重写存在于继承体系中,指子类实现了一个与父类在方法声明上完全相同的一个方法; +- 覆盖(Override)存在于继承体系中,指子类实现了一个与父类在方法声明上完全相同的一个方法; -- 重载即存在于继承体系中,也存在于同一个类中,指一个方法与已经存在的方法或者父类的方法名称上相同,但是参数类型、个数、顺序至少有一个不同。应该注意的是,返回值不同,其它都相同不算是重载。 +- 重载(Overload)也存在于同一个类中,指一个方法与已经存在的方法名称上相同,但是参数类型、个数、顺序至少有一个不同。应该注意的是,返回值不同,其它都相同不算是重载。 # 五、String diff --git a/notes/剑指 offer 题解.md b/notes/剑指 offer 题解.md index 7a178346..4a6c375c 100644 --- a/notes/剑指 offer 题解.md +++ b/notes/剑指 offer 题解.md @@ -1986,6 +1986,7 @@ public int longestSubStringWithoutDuplication(String str) { int curLen = 0; int maxLen = 0; int[] indexs = new int[26]; + Arrays.fill(indexs, -1); for (int i = 0; i < str.length(); i++) { int c = str.charAt(i) - 'a'; int preIndex = indexs[c]; @@ -2010,21 +2011,19 @@ public int longestSubStringWithoutDuplication(String str) { ## 解题思路 ```java -public int GetUglyNumber_Solution(int N) { - if (N <= 6) return N; +public int GetUglyNumber_Solution(int index) { + if (index <= 6) return index; int i2 = 0, i3 = 0, i5 = 0; - int cnt = 1; - int[] dp = new int[N]; + int[] dp = new int[index]; dp[0] = 1; - while (cnt < N) { + for (int i = 1; i < index; i++) { int n2 = dp[i2] * 2, n3 = dp[i3] * 3, n5 = dp[i5] * 5; - int min = Math.min(n2, Math.min(n3, n5)); - dp[cnt++] = min; - if (min == n2) i2++; - if (min == n3) i3++; - if (min == n5) i5++; + dp[i] = Math.min(n2, Math.min(n3, n5)); + if (dp[i] == n2) i2++; + if (dp[i] == n3) i3++; + if (dp[i] == n5) i5++; } - return dp[N - 1]; + return dp[index - 1]; } ```