Skip to content

Commit 4b36935

Browse files
Update 1929. Concatenation of Array.py
1 parent cccef91 commit 4b36935

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
class Solution:
22
def getConcatenation(self, nums: List[int]) -> List[int]:
3-
nums_length = len(nums) * 2
3+
'''
4+
getConcatenation takes an input array nums and concatenates it with itself
5+
nums: int array (n == nums.length, 1 <= n <= 1000, 1 <= nums[i] <= 1000)
6+
'''
7+
nums_length = len(nums) * 2 #double the length of array nums
48
nums_concat = []
5-
while len(nums_concat) < nums_length:
6-
for i in range(len(nums)):
9+
while len(nums_concat) < nums_length: #iterate through array nums twice
10+
for i in range(len(nums)): #add each character to new array
711
nums_concat.append(nums[i])
812
return nums_concat

0 commit comments

Comments
 (0)