Skip to content

Commit 7275b36

Browse files
authored
Added tasks 960-1012
1 parent 6e9c1a3 commit 7275b36

File tree

65 files changed

+4399
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4399
-20
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Large diffs are not rendered by default.

src/main/kotlin/g0901_1000/s0901_online_stock_span/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class StockSpanner {
6868
if (stocks.size == 1) {
6969
return index - stocks.peek()
7070
}
71-
while (stocks.size > 1 && map[stocks.peek()]!! <= price) {
71+
while (stocks.size > 1 && map.getValue(stocks.peek()) <= price) {
7272
stocks.pop()
7373
}
7474
return index - stocks.peek()

src/main/kotlin/g0901_1000/s0909_snakes_and_ladders/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Solution {
7373
queue.add(1)
7474
visited[0] = true
7575
var step = 0
76-
while (!queue.isEmpty()) {
76+
while (queue.isNotEmpty()) {
7777
val queueSize = queue.size
7878
for (i in 0 until queueSize) {
7979
val previousLabel = queue.poll()

src/main/kotlin/g0901_1000/s0913_cat_and_mouse/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Solution {
9898
q.offer(intArrayOf(0, i, CAT, MOUSE_WIN))
9999
q.offer(intArrayOf(i, i, CAT, CAT_WIN))
100100
}
101-
while (!q.isEmpty()) {
101+
while (q.isNotEmpty()) {
102102
val state = q.poll()
103103
val mouse = state[0]
104104
val cat = state[1]

src/main/kotlin/g0901_1000/s0914_x_of_a_kind_in_a_deck_of_cards/readme.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ class Solution {
4343
val map: HashMap<Int, Int> = HashMap()
4444
for (j in deck) {
4545
if (map.containsKey(j)) {
46-
map[j] = map[j]!! + 1
46+
map[j] = map.getValue(j) + 1
4747
} else {
4848
map[j] = 1
4949
}
5050
}
51-
var x = map[deck[0]]!!
52-
51+
var x = map.getValue(deck[0])
5352
for (entry in map.entries.iterator()) {
5453
x = gcd(x, entry.value)
5554
}

src/main/kotlin/g0901_1000/s0919_complete_binary_tree_inserter/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class CBTInserter(root: TreeNode?) {
6868
private fun addToQueue() {
6969
val hlq: Queue<TreeNode> = LinkedList()
7070
hlq.add(head)
71-
while (!hlq.isEmpty()) {
71+
while (hlq.isNotEmpty()) {
7272
var size = hlq.size
7373
while (size-- > 0) {
7474
val poll: TreeNode = hlq.poll()
@@ -97,7 +97,7 @@ class CBTInserter(root: TreeNode?) {
9797
}
9898

9999
private fun deleteFullNode() {
100-
while (!q.isEmpty()) {
100+
while (q.isNotEmpty()) {
101101
val peek: TreeNode = q.peek()
102102
if (peek.left != null && peek.right != null) {
103103
q.poll()

src/main/kotlin/g0901_1000/s0921_minimum_add_to_make_parentheses_valid/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Solution {
4545
val stack: Deque<Char> = LinkedList()
4646
for (c in s.toCharArray()) {
4747
if (c == ')') {
48-
if (!stack.isEmpty() && stack.peek() == '(') {
48+
if (stack.isNotEmpty() && stack.peek() == '(') {
4949
stack.pop()
5050
} else {
5151
stack.push(c)

src/main/kotlin/g0901_1000/s0928_minimize_malware_spread_ii/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Solution {
6464
visited!!.add(initial[i])
6565
}
6666
}
67-
while (!q.isEmpty()) {
67+
while (q.isNotEmpty()) {
6868
val curr = q.poll()
6969
if (curr != initial[ind]) {
7070
count++
@@ -87,7 +87,7 @@ class Solution {
8787
adj.putIfAbsent(i, ArrayList())
8888
for (j in 0 until n) {
8989
if (graph[i][j] == 1) {
90-
adj[i]!!.add(j)
90+
adj.getValue(i).add(j)
9191
}
9292
}
9393
}
@@ -96,7 +96,7 @@ class Solution {
9696
var node = initial[0]
9797
for (i in initial.indices) {
9898
visited = HashSet()
99-
val children = adj[initial[i]]!!
99+
val children = adj.getValue(initial[i])
100100
adj.remove(initial[i])
101101
bfs(i, initial)
102102
if (count < min) {

src/main/kotlin/g0901_1000/s0934_shortest_bridge/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Solution {
6767
i++
6868
}
6969
var level = -1
70-
while (!q.isEmpty()) {
70+
while (q.isNotEmpty()) {
7171
var size: Int = q.size
7272
level++
7373
while (size-- > 0) {

src/main/kotlin/g0901_1000/s0939_minimum_area_rectangle/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Solution {
4646
val map: MutableMap<Int, MutableSet<Int>> = HashMap()
4747
for (p in points) {
4848
map.putIfAbsent(p[0], HashSet())
49-
map[p[0]]!!.add(p[1])
49+
map.getValue(p[0]).add(p[1])
5050
}
5151
Arrays.sort(
5252
points
@@ -65,7 +65,7 @@ class Solution {
6565
if (area >= min || area == 0) {
6666
continue
6767
}
68-
if (map[p1[0]]!!.contains(p2[1]) && map[p2[0]]!!.contains(p1[1])) {
68+
if (map.getValue(p1[0]).contains(p2[1]) && map.getValue(p2[0]).contains(p1[1])) {
6969
min = area
7070
}
7171
}

0 commit comments

Comments
 (0)