DEV Community

Piyush Acharya
Piyush Acharya

Posted on

FASTEST JAVA SOLUTION 🔥🔥🔥

Code

class Solution {
    public int[] shuffle(int[] nums, int n) {
        int[] newNums = new int[nums.length];
        for (int i = 0; i < n; i++) { 
            newNums[i * 2] = nums[i];
        }
        for (int j = 1; j < nums.length; j += 2) {
            newNums[j] = nums[n + (j / 2)];
        }
        return newNums;
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)