Tuesday, February 16, 2021

Leetcode Everyday: 1389. Create Target Array in the Given Order. Easy

public class Solution {
    public int[] CreateTargetArray(int[] nums, int[] indexes) {    
        var list = new List<int>();
        
        foreach (var (num, index) in nums.Zip(indexes, (num, index) => (num, index))) {
            list.Insert(index, num);
        }
        return list.ToArray();
    }
}
Source: https://leetcode.com/problems/create-target-array-in-the-given-order/

No comments:

Post a Comment