Problem · Array

Combine Two Index Sequences

Learn this problem
EasySquarepoint Capital logoSquarepoint CapitalFULLTIMEPHONE SCREEN

Problem statement

You are given two finite index sequences, first and second. Return their concatenation: every value of first in its original order followed by every value of second in its original order.

Do not sort, merge, or remove duplicates. Either sequence may be empty.

Function

combineIndexSequences(first: int[], second: int[]) → int[]

Examples

Example 1

first = [0,2,4]second = [1,3]return = [0,2,4,1,3]

The first sequence is followed by the second without reordering.

Example 2

first = []second = [5,6]return = [5,6]

Only the second sequence contributes values.

Example 3

first = [7,8]second = []return = [7,8]

Only the first sequence contributes values.

Constraints

  • 0 <= first.length, second.length <= 200000.
  • first.length + second.length <= 200000.
  • Every value is a signed 32-bit integer.

More Squarepoint Capital problems

drafts saved locally
public int[] combineIndexSequences(int[] first, int[] second) {
  // write your code here
}
first[0,2,4]
second[1,3]
expected[0,2,4,1,3]
checking account