FastPrepInterleave Array Halves
Problems/Interleave Array Halves

Interleave Array Halves

Morgan Stanley logoMorgan Stanley● EasyINTERNOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The judged task matches the report at about 95%. The bounds and empty-input behavior are practice assumptions; duplicate coupon numbers and the reported example are preserved.

You are given an array coupons of even length 2m. Interleave its first and second halves, taking one element from the first half followed by the matching element from the second half.

Return [coupons[0], coupons[m], coupons[1], coupons[m + 1], ...]. Keep the order within each half. Equal coupon numbers remain separate elements.

For this exercise, assume an empty input returns an empty array. Return a new array and leave coupons unchanged.

Function

interleaveHalves(coupons: int[]) → int[]

Examples

Example 1

coupons = [4,4,4,4,8,3,5,9]return = [4,8,4,3,4,5,4,9]

The first half is [4,4,4,4] and the second half is [8,3,5,9]. Pairing their elements in order gives [4,8,4,3,4,5,4,9]; all four copies of 4 are kept.

Example 2

coupons = [1,2,10,20]return = [1,10,2,20]

The halves are [1,2] and [10,20]. Take 1, then 10, then 2, then 20.

Constraints

  • For this exercise, assume 0 <= coupons.length <= 2000.
  • The length of coupons is even.
  • For this exercise, assume 0 <= coupons[i] <= 10^9.

More Morgan Stanley problems

  • Unique Grid PathsPHONE SCREEN · Seen Oct 2026
  • Generate Strings of Length at Least ThreeONSITE INTERVIEW · Seen Sep 2026
  • Three-Resource 0/1 KnapsackOA · Seen Sep 2026
All Morgan Stanley interview questionsSee Morgan Stanley hiring insights
Saved
class Solution {
    public int[] interleaveHalves(int[] coupons) {
        // Write your code here.
    }

}
Checking account…