Python and C++ Easy Solutions - Multiple Approaches with O(N)
If you want a detailed explanation of the solutions, please check out https://helloml.org/concatenation-of-array-solution-to-leetcode-problem/. \n\n# Python O(N
If you want a detailed explanation of the solutions, please check out https://helloml.org/concatenation-of-array-solution-to-leetcode-problem/. \n\n# Python O(N)\n```python\nclass Solution:\n    def getConcatenation(self, nums: List[int]) -> List[int]:\n        n = len(nums)\n        for i in range(0, n):\n            nums.append(nums[i])\n        return nums\n```\n# C++ O(N)\n```cpp\nclass Solution {\npublic:\n    vector<int> getConcatenation(vector<int>& nums) {\n        int n = nums.size();\n        for(int i = 0; i < n; i++) {\n            nums.push_back(nums[i]);\n        }\n        return nums;\n    }\n};\n```\n# Python O(N)\nAs pointed by [@alexnik42](https://leetcode.com/alexnik42), Python takes O(n+m) for adding/concatenating two lists. \n```python\nclass Solution:\n    def getConcatenation(self, nums: List[int]) -> List[int]:\n        return nums+nums\n```\n# C++ O(N)\n**Edit:** I assumed that the `insert()` operation took O(1) time. As @itisamystery pointed out, turns out that `insert()` takes O(n) time. Sorry for the confusion. \n```cpp\nclass Solution {\npublic:\n    vector<int> getConcatenation(vector<int>& nums) {\n        nums.insert(nums.end(), nums.begin(), nums.end());\n        return nums;\n    }\n};\n```
['C', 'Python', 'C++']