Algorithm/LeetCode

1929. Concatenation of Array

유쾌한고등어 2023. 1. 1. 23:14

https://leetcode.com/problems/concatenation-of-array/description/

 

Concatenation of Array - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

주어진 배열 nums의 길이X2만큼, 배열원소를 그대로 복사해서 늘려서 반환하는문제

Too easy!


SOLUTION CODE

# PYTHON

class Solution(object):
    def getConcatenation(self, nums):
        """
        :type nums: List[int]
        :rtype: List[int]
        """
        res = nums

        for i in range(len(nums)):
            res.append(nums[i])
        return res

# C++

class Solution {
public:
    vector<int> getConcatenation(vector<int>& nums) {
        nums.insert(nums.end(),nums.begin(),nums.end());
        return nums;
    }
};