leetcode - Shuffle the Array

 

LeetCode

Code
class Solution {
    public int[] shuffle(int[] nums, int n) {
        int[] result = new int[nums.length];
        int currentIdx = 0;
        for (int i = 0; i < n; i++) {
            result[currentIdx] = nums[i];
            result[currentIdx+1] = nums[i+n];
            currentIdx += 2;
        }
        return result;
    }
}

沒有留言:

張貼留言

Lessons Learned While Using Claude Code Skills

Recently, I started experimenting with Claude Code Skills . I first saw this YouTube video: https://www.youtube.com/watch?v=CEvIs9y1uog ...