Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d25b12

Browse files
authored
Create 0452-minimum-number-of-arrows-to-burst-balloons.kt
1 parent44fd478 commit2d25b12

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
classSolution {
2+
funfindMinArrowShots(points:Array<IntArray>):Int {
3+
points.sortWith(compareBy({ it[0] }, { it[1] }))
4+
5+
var res= points.size
6+
var prev= points[0]
7+
for (iin1 until points.size) {
8+
val curr= points[i]
9+
if (curr[0]<= prev[1]) {
10+
res--
11+
prev[0]= curr[0]
12+
prev[1]= minOf(curr[1], prev[1])
13+
}else {
14+
prev= curr
15+
}
16+
}
17+
18+
return res
19+
}
20+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp