力扣:数组串联



/**
 * @author xnl
 * @Description:
 * @date: 2022/7/31   22:10
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();

    }

    public int[] getConcatenation(int[] nums) {
        int n = nums.length;
        int[] ans = new int[n * 2];
        for (int i = 0; i < n; i++){
            ans[i] = nums[i];
            ans[i + n] = nums[i];
        }
        return ans;
    }
}

你可能感兴趣的:(算法,菜鸟刷题记录,leetcode,算法,c++)