Skip to content

Commit 10ff044

Browse files
committed
docs: update README.md
1 parent 1d9a37a commit 10ff044

File tree

4 files changed

+93
-4
lines changed

4 files changed

+93
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
| 题目 | 题解 | kotlin | JavaScript | Java |
1515
| :-----------------: | -------------------------------------- | :--------------: | :-------: | :------------: |
1616
| [1][1-question] | [Two Sum][1-tips] | [][1-kotlin] | | [][1-java] |
17-
| [771][771-question] | [Jewels and Stones][771-tips] | [][771-kotlin] | | [][771-java] |
1817
| [728][728-question] | [Self Dividing Numbers][728-tips] | | | [][728-java] |
18+
| [771][771-question] | [Jewels and Stones][771-tips] | [][771-kotlin] | | [][771-java] |
1919
| [804][804-question] | [Unique Morse Code Words][804-tips] | | | [][804-java] |
2020

2121

@@ -36,22 +36,22 @@
3636

3737
[1-question]: https://leetcode.com/problems/two-sum/description/
3838
[2-question]: https://leetcode.com/problems/add-two-numbers/description/
39+
[728-question]: https://leetcode.com/problems/self-dividing-numbers/description/
3940
[771-question]: https://leetcode.com/problems/jewels-and-stones/description/
4041
[804-question]: https://leetcode.com/problems/unique-morse-code-words/description/
41-
[728-question]: https://leetcode.com/problems/self-dividing-numbers/description/
4242

4343
[1-tips]: ./tips/1/README.md
4444
[2-tips]: ./tips/2/README.md
45+
[728-tips]: ./tips/728/README.md
4546
[771-tips]: ./tips/771/README.md
4647
[804-tips]: ./tips/804/README.md
47-
[728-tips]: ./tips/728/README.md
4848

4949
[1-kotlin]: ./src/_1/kotlin/Solution.kt
5050
[2-kotlin]: ./src/_2/kotlin/Solution.kt
5151
[771-kotlin]: ./src/_771/kotlin/Solution.kt
5252

5353
[1-java]: ./src/_1/Solution.java
5454
[2-java]: ./src/_2/Solution.java
55+
[728-java]: ./src/_728/Solution.java
5556
[771-java]: ./src/_771/Solution.java
5657
[804-java]: ./src/_804/Solution.java
57-
[728-java]: ./src/_728/Solution.java

src/_514/MainClass.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package _514;
2+
3+
class Solution {
4+
5+
public int findRotateSteps(String ring, String key) {
6+
return 0;
7+
}
8+
9+
public static void main(String[] args) {
10+
System.out.println(new Solution().findRotateSteps("godding", "gd"));
11+
}
12+
}

src/_729/MyCalendar.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package _729;
2+
// remove the line of `package xxx.xxx.xxx.xxx;` when you commit it
3+
4+
import java.util.TreeMap;
5+
6+
/**
7+
* @author relish
8+
* @since 2018/04/02
9+
*/
10+
11+
class MyCalendar {
12+
13+
public MyCalendar() {
14+
15+
}
16+
17+
private TreeMap<Integer, Integer> map = new TreeMap<>();
18+
19+
public boolean book(int start, int end) {
20+
TreeMap<Integer, Integer> d = new TreeMap<>(map);
21+
d.put(start, d.getOrDefault(start, 0) + 1);
22+
d.put(end, d.getOrDefault(end, 0) - 1);
23+
int sum = 0;
24+
for (Integer integer : d.values()) {
25+
sum += integer;
26+
if (sum > 1) {
27+
return false;
28+
}
29+
}
30+
map = new TreeMap<>(d);
31+
return true;
32+
}
33+
34+
public static void main(String[] args) {
35+
MyCalendar myCalendar = new MyCalendar();
36+
System.out.println(myCalendar.book(10, 20)); // returns true
37+
System.out.println(myCalendar.book(15, 25)); // returns false
38+
System.out.println(myCalendar.book(20, 30)); // returns true
39+
}
40+
}
41+

src/_732/MyCalendarThree.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package _732;
2+
3+
import java.util.TreeMap;
4+
5+
class MyCalendarThree {
6+
7+
8+
public MyCalendarThree() {
9+
}
10+
11+
TreeMap<Integer, Integer> timeline = new TreeMap<>();
12+
13+
public int book(int start, int end) {
14+
timeline.put(start, timeline.getOrDefault(start, 0) + 1);
15+
timeline.put(end, timeline.getOrDefault(end, 0) - 1);
16+
int sum = 0;
17+
int max = 0;
18+
for (Integer integer : timeline.values()) {
19+
sum += integer;
20+
max = Math.max(max, sum);
21+
}
22+
return max;
23+
}
24+
}
25+
26+
class Main {
27+
public static void main(String[] args) {
28+
MyCalendarThree myCalendarThree = new MyCalendarThree();
29+
System.out.println(myCalendarThree.book(10, 20));//1
30+
System.out.println(myCalendarThree.book(50, 60));//1
31+
System.out.println(myCalendarThree.book(10, 40));//2
32+
System.out.println(myCalendarThree.book(5, 15));//3
33+
System.out.println(myCalendarThree.book(5, 10));//3
34+
System.out.println(myCalendarThree.book(25, 55));//3
35+
}
36+
}

0 commit comments

Comments
 (0)