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/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Tuesday, February 16, 2021
Leetcode Everyday: 1389. Create Target Array in the Given Order. Easy
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment