FastPrepStable Array Partition
Problems/Stable Array Partition

Stable Array Partition

Roblox logoRoblox● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Roblox new grad onsite interview. The report mentions a two-pointer task that splits an array, without the rule for the split. We chose a pivot that you are given, a strict less-than group, a stable order, a new array as the output, and the limits. Our version is about 65% the same as the reported question.

You are given an integer array nums and a value pivot. Split the values into two groups.

For this exercise, assume all values strictly less than pivot must appear first, followed by all values greater than or equal to it. Within each group, keep the values in their original order.

Return the two groups together in a new array and leave the input unchanged. Preserve duplicates, and place values equal to the pivot in the second group. An empty input returns an empty array.

Function

stablePartition(nums: int[], pivot: int) → int[]

Examples

Example 1

nums = [9,1,5,2,5,7]pivot = 5return = [1,2,9,5,5,7]

Values 1 and 2 come first. Both groups retain their input order.

Example 2

nums = [3,2,1,2]pivot = 2return = [1,3,2,2]

The value 1 is the only value strictly below 2; equal values belong to the second group.

Example 3

nums = []pivot = 0return = []

An empty input has no values to partition.

Constraints

  • 0 <= nums.length <= 1000.
  • -10^9 <= nums[i], pivot <= 10^9.

More Roblox Onsite Interview questions

  • Most Frequent Call Path From Function Trace LogsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Count and Score Distinct Hat AssignmentsONSITE INTERVIEW · Seen Sep 2026
  • Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Most Frequent Call Path in Interleaved LogsONSITE INTERVIEW · Seen Aug 2026
  • Grid Pathfinding with Obstacles (DFS)PHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026
  • Maximize Distance to Closest Person — Return the SeatONSITE INTERVIEW · Seen Jun 2026

Similar questions at other companies

  • Merge Sorted ArrayDP World · ONSITE INTERVIEW
  • Remove Duplicates From Sorted Array In PlaceKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Maximize Distance to the Closest Occupied SeatAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Merge Two Arrays Into Sorted OrderNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Alternate Positive and Negative ValuesTesla · ONSITE INTERVIEWTesla interview questions
  • Sparse Vector Dot Product from TuplesMeta · ONSITE INTERVIEWMeta interview questions
  • Make a Sorted Array Unique In PlaceAlpaca · ONSITE INTERVIEW
  • Two SumMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Move ZeroesBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Rotate an Array to the RightScale AI · ONSITE INTERVIEWScale AI interview questions

Interview reports that mention this question

  • Roblox New Grad Coding Rounds: 23 Experiences (Part 2 of 7)

Roblox interview experiences

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int[] stablePartition(int[] nums, int pivot) {
        // write your code here
    }

}
Checking account…