Two Python Solutions | Concatenate or Repeat
Intuition\n Describe your first thoughts on how to solve this problem. \nWe need to return a new array that repeats the original array twice.\n\n# Approach\n De
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe need to return a new array that repeats the original array twice.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n### Approach 1\nWe can concatenate the original `nums` array with itself using the `+` operator.\n\n> `+` \u2192 it concatenates two lists in Python:\nExample: `[1, 2, 3] + [1, 2, 3] = [1, 2, 3, 1, 2, 3]`\n\n### Approach 2\nWe can repeat the the original `nums` array `2` times using the `*` operator.\n\n> `*` \u2192 it repeats a list a specified number of times in Python:\nExample: `[1, 2, 3] * 2 = [1, 2, 3, 1, 2, 3]`\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n`n` is the length of the `nums` array. Both solutions require going through each element of the input list once, and the time they take scales linearly with the size of the input list.\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n`n` is the length of the `nums` array. Both solutions create a new list to store the concatenated list, and the space used for this is directly proportional to the size of the input list.\n\n# Code\n## Approach 1 Solution:\n```\nclass Solution:\n    def getConcatenation(self, nums: List[int]) -> List[int]:\n        return nums + nums\n        \n```\n\n## Approach 2 Solution:\n```\nclass Solution:\n    def getConcatenation(self, nums: List[int]) -> List[int]:\n        return nums * 2  \n```
['Python3']