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

Commita03a806

Browse files
authored
Merge pull requestneetcode-gh#1072 from MaratKhakim/973-K-Closest-kt
Kotlin: 973. K Closest Points to Origin
2 parents0b31433 +54cd2f8 commita03a806

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
classSolution {
2+
funkClosest(points:Array<IntArray>,k:Int):Array<IntArray> {
3+
val sorted= points.sortedBy{ it[0]*it[0]+ it[1]*it[1]}
4+
val list= arrayListOf<IntArray>()
5+
6+
for (iin0..k-1) {
7+
list.add(sorted[i])
8+
}
9+
10+
return list.toTypedArray()
11+
}
12+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp