FastPrepPair Left and Right Socks by ID
Problems/Pair Left and Right Socks by ID

Pair Left and Right Socks by ID

Roblox logoRoblox● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Roblox new grad onsite interview. The candidate asks for pairs of left and right socks of the same color, returned by ID. We chose the largest set of pairs that do not overlap, numeric IDs, a fixed ID order, case-sensitive colors, and the limits. Our version is about 80% the same as the reported question.

Each sock has a side, a color and a unique integer ID. The parallel arrays sides, colors and ids describe the socks. A valid pair contains one left sock (L) and one right sock (R) of exactly the same color.

For this exercise, use each sock at most once and make as many pairs as possible. Use these rules to choose the pairs: sort left IDs and right IDs separately within each color, then pair the smallest left with the smallest right, the next-smallest with the next-smallest, and so on until one side is exhausted.

Return the pairs as [leftID, rightID] rows, ordered by increasing left ID across all colors. Unmatched socks are omitted. Color identifiers are case-sensitive; return an empty array when no pair can be formed.

Function

pairSockIds(sides: String[], colors: String[], ids: int[]) → int[][]

Examples

Example 1

sides = ["L","R","L","R"]colors = ["red","blue","blue","red"]ids = [7,2,4,9]return = [[4,2],[7,9]]

Blue pairs left 4 with right 2; red pairs left 7 with right 9. Increasing left ID puts the blue pair first.

Example 2

sides = ["L","L","R","R","L"]colors = ["red","red","red","red","red"]ids = [8,3,6,1,5]return = [[3,1],[5,6]]

Left IDs are 3, 5 and 8; right IDs are 1 and 6. Two pairs are possible, leaving left 8 unmatched.

Example 3

sides = []colors = []ids = []return = []

With no socks, no pairs can be formed.

Constraints

  • 0 <= ids.length <= 500, and sides.length = colors.length = ids.length.
  • Every side is exactly L or R.
  • IDs are distinct integers with 0 <= ids[i] <= 10^9.
  • Each color contains 1 to 16 English letters, digits or underscores.

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

  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Filter Anagrams of a TargetMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Rank Transform an ArrayAgoda · ONSITE INTERVIEWAgoda interview questions
  • Deduplicate Logs: Keep FirstGoogle · ONSITE INTERVIEWGoogle interview questions
  • Loyal Customers by Two-Day Product VarietyAmazon · ONSITE INTERVIEW
  • Restaurant Vote LeadersZipRecruiter · PHONE SCREEN · ONSITE INTERVIEWZipRecruiter interview questions
  • High-Severity Counts by Search TypeChainalysis · ONSITE INTERVIEWChainalysis interview questions
  • Intersection of Two ListsJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Net Position Calculation from API SnapshotsHeadlands Technologies · ONSITE INTERVIEWHeadlands Technologies interview questions
  • Count Word FrequenciesBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions

Interview reports that mention this question

  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 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[][] pairSockIds(String[] sides, String[] colors, int[] ids) {
        // write your code here
    }

}
Checking account…