Skip to content

Commit 4988be4

Browse files
committed
20220911
1 parent 1c80a1a commit 4988be4

File tree

16 files changed

+1534
-30
lines changed

16 files changed

+1534
-30
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 48 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,92 @@ Notes:!!
571571

572572
---
573573

574-
### [20220825](src/main/kotlin/_2022/_08/_202208.kt)
574+
### [20220824](src/main/kotlin/_2022/_08/_202208.kt)
575575

576576
| Difficulty | Marks | Name | link |
577577
|:----------:|:-----:|-----------------|--------------------------------------------------------|
578578
| 🟠 || 79. Word Search | [Leetcode](https://leetcode.com/problems/word-search/) |
579579

580580
---
581581

582-
### [202208](src/main/kotlin/_2022/_08/_202208.kt)
582+
### [20220825](src/main/kotlin/_2022/_08/_20220825.kt)
583+
584+
| Difficulty | Marks | Name | link |
585+
|:----------:|:-----:|-------------------------------------------|--------------------------------------------------------------------|
586+
| 🟠 || 131. Palindrome Partitioning | [Leetcode](https://leetcode.com/problems/palindrome-partitioning/) |
587+
| 🟠 | ✅❗❓❌ | 17. Letter Combinations of a Phone Number | [Leetcode]() |
588+
589+
590+
---
591+
592+
### [20220826](src/main/kotlin/_2022/_08/_20220826.kt)
593+
594+
| Difficulty | Marks | Name | link |
595+
|:----------:|:-----:|------|--------------|
596+
| 🟠 || 663 · Walls and Gates | [Leetcode](https://www.lintcode.com/problem/663/) |
597+
| 🟠 || 207. Course Schedule | [Leetcode](https://leetcode.com/problems/course-schedule/submissions/) |
598+
599+
600+
- 207: S1
601+
602+
---
603+
### [20220827](src/main/kotlin/_2022/_08/_20220827.kt)
604+
605+
| Difficulty | Marks | Name | link |
606+
|:----------:|:-----:|---------------------------|--------------------------------------------------------------------|
607+
| 🟠 | ✅❗❓❌ | 684. Redundant Connection | [Leetcode](// https://leetcode.com/problems/redundant-connection/) |
608+
609+
610+
---
611+
### [20220828](src/main/kotlin/_2022/_08/_20220828.kt)
612+
613+
| Difficulty | Marks | Name | link |
614+
|:----------:|:-----:|------|--------------|
615+
| 🟠 || 2385. Amount of Time for Binary Tree to Be Infected | [Leetcode](https://leetcode.com/problems/amount-of-time-for-binary-tree-to-be-infected/) |
616+
617+
- 2385: S1
618+
619+
---
620+
### [20220829](src/main/kotlin/_2022/_08/_20220829.kt)
621+
622+
| Difficulty | Marks | Name | link |
623+
|:----------:|:-----:|------|--------------|
624+
| 🔴 | ✅❗❓❌ | 4. Median of Two Sorted Arrays | [Leetcode]() |
625+
626+
---
627+
### [20220907](src/main/kotlin/_2022/_08/_202208.kt)
628+
629+
| Difficulty | Marks | Name | link |
630+
|:----------:|:-----:|-----------------------------|-------------------------------------------------------------------|
631+
| 🟠 | ✅❗❓❌ | 8. String to Integer (atoi) | [Leetcode](https://leetcode.com/problems/string-to-integer-atoi/) |
632+
| 🟠 | ✅❗❓❌ | 56. Merge Intervals | [Leetcode](https://leetcode.com/problems/merge-intervals/) |
633+
634+
635+
- 8: stupid ass question, not worth looking at
636+
637+
---
638+
### [20220908](src/main/kotlin/_2022/_08/_20220908.kt)
639+
640+
| Difficulty | Marks | Name | link |
641+
|:----------:|:-----:|------|-------------------------------------------------------------------------|
642+
| 🟠 || 435. Non-overlapping Intervals | [Leetcode](https://leetcode.com/problems/non-overlapping-intervals/) |
643+
| 🟠 | ✅❗❓❌ | Lintcode 919 · Meeting Rooms II | [Leetcode](https://leetcode.com/problems/meeting-rooms-ii/) [youtube](https://www.youtube.com/watch?v=FdzJmTCVyJU) |
644+
645+
---
646+
### [20220911](src/main/kotlin/_2022/_08/_20220911.kt)
647+
648+
| Difficulty | Marks | Name | link |
649+
|:----------:|:-----:|--------------------------|----------------------------------------------------------------|
650+
| 🟠 || | [Leetcode](https://leetcode.com/problems/fruit-into-baskets/) |
651+
| 🟠 || 73. Set Matrix Zeroes | [Leetcode](https://leetcode.com/problems/set-matrix-zeroes/) |
652+
| 🟠 || 50. Pow(x, n) | [Leetcode](https://leetcode.com/problems/powx-n/) |
653+
| 🟠 | ✅❗❓❌ | 371. Sum of Two Integers | [Leetcode](https://leetcode.com/problems/sum-of-two-integers/) |
654+
| 🟢 | ✅❗❓❌ | 202. Happy Number | [Leetcode](https://leetcode.com/problems/happy-number/) |
655+
| 🟢 | ✅❗❓❌ | 66. Plus One | [Leetcode](https://leetcode.com/problems/plus-one) |
656+
657+
658+
---
659+
### [202209](src/main/kotlin/_2022/_08/_202209.kt)
583660

584661
| Difficulty | Marks | Name | link |
585662
|:----------:|:-----:|------|--------------|
@@ -616,4 +693,12 @@ Notes:!!
616693
- [GitHub - youngyangyang04/leetcode-master: 🚀](https://github.com/youngyangyang04/leetcode-master) 《代码随想录》LeetCode 刷题攻略:200道经典题目刷题顺序
617694
- [LABULADONG 的算法网站](https://labuladong.github.io/algo/)
618695

619-
---
696+
---
697+
698+
699+
### To-Do list
700+
- https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/
701+
- https://leetcode.com/problems/graph-valid-tree/
702+
- https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
703+
- https://leetcode.com/problems/palindrome-partitioning/submissions/
704+
- https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-inorder-traversal/

src/main/kotlin/Main.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _2022._07.*
22
import _2022._08.*
3+
import _2022._09._20220908
34

45
fun main(args: Array<String>) {
56

@@ -14,8 +15,10 @@ fun main(args: Array<String>) {
1415
// _20220811,
1516
// _20220812,
1617
// _20220814,
17-
_20220815,
18-
18+
// _20220815,
19+
// _20220826,
20+
// _20220827,
21+
_20220908
1922
).flatten()
2023

2124
for (i in tests.indices) {

src/main/kotlin/_2022/_08/_20220818.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,3 @@ private interface Leetcode_295 {
4444

4545

4646
}
47-
48-
49-
val _202208 = listOf<Testable>(
50-
51-
)
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
@file:Suppress("DuplicatedCode", "ClassName", "ObjectPropertyName")
2+
3+
package _2022._08
4+
5+
import Testable
6+
import utils.assertEqualTo
7+
import utils.runTimedTests
8+
9+
10+
// 131. Palindrome Partitioning
11+
// https://leetcode.com/problems/palindrome-partitioning/
12+
private interface LC_131 {
13+
fun partition(s: String): List<List<String>>
14+
15+
// not working
16+
private class M1 : LC_131 {
17+
val res = ArrayList<ArrayList<String>>()
18+
val cur = ArrayList<String>()
19+
20+
override fun partition(s: String): List<List<String>> {
21+
dfs(s, 0, 0)
22+
return res
23+
}
24+
fun dfs(s: String, left: Int, right: Int) {
25+
if (left > right) return
26+
if (right >= s.length) return
27+
28+
if (right == s.length-1) {
29+
if (cur.isNotEmpty()) {
30+
res.add(ArrayList(cur))
31+
cur.clear()
32+
}
33+
}
34+
35+
if (isPalindrome(s, left, right)) cur.add(s.substring(left, right+1))
36+
37+
for (r in right+1 until s.length-1){
38+
dfs(s, left, r)
39+
}
40+
41+
dfs(s, left+1, left+2)
42+
}
43+
fun isPalindrome(s: String, left: Int, right: Int) : Boolean {
44+
if (left < 0 || right >= s.length || left > right) return false
45+
if (left == right) return true
46+
47+
var left = left
48+
var right = right
49+
50+
while(left <= right) {
51+
if (s[left] != s[right]) return false
52+
left--
53+
right++
54+
}
55+
return true
56+
}
57+
}
58+
}
59+
60+
61+
// 17. Letter Combinations of a Phone Number
62+
// https://leetcode.com/problems/letter-combinations-of-a-phone-number/
63+
private interface LC_17 {
64+
fun letterCombinations(digits: String): List<String>
65+
66+
private class M1 : LC_17 {
67+
val map = arrayOf(
68+
charArrayOf(), // 0
69+
charArrayOf(), // 1
70+
"abc".toCharArray(),
71+
"def".toCharArray(),
72+
"ghi".toCharArray(),
73+
"jkl".toCharArray(),
74+
"mno".toCharArray(),
75+
"pqrs".toCharArray(),
76+
"tuv".toCharArray(),
77+
"wxyz".toCharArray()
78+
)
79+
80+
override fun letterCombinations(digits: String): List<String> {
81+
var res = ArrayList<String>()
82+
val list = digits.map { map[it-'0'] }
83+
84+
for (d in list) {
85+
if (res.isEmpty()) {
86+
res.addAll(d.map { it.toString() })
87+
} else {
88+
res.flatMap { s ->
89+
d.map { "$s$it" }
90+
}.also {
91+
res = ArrayList(it)
92+
}
93+
}
94+
}
95+
return res
96+
}
97+
}
98+
}
99+
100+
101+
val _20220825 = listOf<Testable>(
102+
103+
)

0 commit comments

Comments
 (0)