FastPrepMerge One List Between Two Positions
Problems/Merge One List Between Two Positions

Merge One List Between Two Positions

Oracle logoOracle● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report establishes the task identity and central capability. This practice contract supplies only the portable interface, deterministic boundary rules, and output serialization needed for consistent execution.

list1 and list2 contain linked-list node values in traversal order. Remove the inclusive range of nodes from index a through index b in list1, and splice all nodes of list2 in their place.

Return the resulting node values.

Function

mergeInBetween(list1: int[], a: int, b: int, list2: int[]) → int[]

Examples

Example 1

list1 = [0,1,2,3,4,5]a = 3b = 4list2 = [1000000,1000001,1000002]return = [0,1,2,1000000,1000001,1000002,5]

Values at indices 3 and 4 are replaced by the second list.

Example 2

list1 = [1,2,3]a = 0b = 2list2 = [9]return = [9]

Replacing the full first list leaves only the inserted list.

Constraints

  • 1 <= list1.length <= 100000.
  • 0 <= a <= b < list1.length.
  • 0 <= list2.length <= 100000.

More Oracle problems

  • Maximum Subarray Sum with One DeletionONSITE INTERVIEW · Seen Nov 2026
  • Shortest Deletion for Distinct CharactersONSITE INTERVIEW · Seen Nov 2026
  • Count Dropped Rate-Limited RequestsONSITE INTERVIEW · Seen Nov 2026
All Oracle interview questionsSee Oracle hiring insights
Saved
class Solution {
    public int[] mergeInBetween(int[] list1, int a, int b, int[] list2) {
      // write your code here
    }
}
Checking account…