Skip to content

Commit 2ce84be

Browse files
Merge pull request #188
add new problem 6.05
2 parents 1ee54ca + 7773fc6 commit 2ce84be

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

contest/src/main/java/com/github/contest/array/ArrayLeetcode.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,18 @@ fun summaryRanges(nums: IntArray): List<String> {
242242
return result
243243
}
244244

245+
/**
246+
* 1920. Build Array from Permutation
247+
*/
248+
249+
250+
fun buildArray(nums: IntArray): IntArray {
251+
val new = IntArray(nums.size)
252+
253+
nums.forEachIndexed { index, _ ->
254+
new[index] = nums[nums[index]]
255+
}
256+
257+
return new
258+
}
245259

0 commit comments

Comments
 (0)