We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1143fc8 commit 0b9e7b8Copy full SHA for 0b9e7b8
Algorithms/1331_Rank_Transform_of_an_Array/Solution.kt
@@ -0,0 +1,15 @@
1
+/**
2
+ * @author occidere
3
+ * @Blog: https://blog.naver.com/occidere
4
+ * @Github: https://github.com/occidere
5
+ * @since 2023-01-01
6
+ */
7
+class Solution {
8
+ fun arrayRankTransform(arr: IntArray): IntArray {
9
+ val rankMap = arr.asSequence()
10
+ .toSortedSet()
11
+ .withIndex()
12
+ .associate { (i, x) -> x to i + 1 }
13
+ return arr.map { rankMap[it]!! }.toIntArray()
14
+ }
15
+}
0 commit comments