We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 94bbd8b commit ae57b64Copy full SHA for ae57b64
kotlin/1929-concatenation-of-array.kt
@@ -0,0 +1,27 @@
1
+/*
2
+* Can be generalized to repeat(x) easier
3
+*/
4
+class Solution {
5
+ fun getConcatenation(nums: IntArray): IntArray {
6
+ val ans = LinkedList<Int>()
7
+ repeat(2) {
8
+ for(num in nums)
9
+ ans.addLast(num)
10
+ }
11
+ return ans.toIntArray()
12
13
+}
14
+
15
16
+* concrete solution
17
18
19
20
+ val ans = IntArray(nums.size * 2)
21
+ for(i in 0..nums.lastIndex) {
22
+ ans[i] = nums[i]
23
+ ans[i + nums.size] = nums[i]
24
25
+ return ans
26
27
0 commit comments