Guaranteed Left-and-Right Sock Pair
Updated
Problem statement
You have socks of several colors. For each color i, there are pairCounts[i] left socks and the same number of right socks.
For this exercise, assume socks are drawn one at a time without replacement in an arbitrary order. A usable pair consists of one left sock and one right sock of the same color. Two socks of the same side do not form a usable pair.
Return the minimum number of draws that guarantees at least one usable pair for every possible drawing order.
The puzzle uses 12 red, 10 black, 8 green and 6 blue pairs. Here the per-color counts are an input. Complete minimumGuaranteedSockDraws(pairCounts) and return a signed 64-bit integer. The total pair count is positive.
Function
minimumGuaranteedSockDraws(pairCounts: int[]) → longExamples
Example 1
pairCounts = [12,10,8,6]return = 37A pair-free prefix has at most 36 socks; one more guarantees a match.
Example 2
pairCounts = [1]return = 2A pair-free prefix has at most 1 sock; one more guarantees a match.
Example 3
pairCounts = [0,2,0,1]return = 4A pair-free prefix has at most 3 socks; one more guarantees a match.
Constraints
- For this exercise, assume
1 <= pairCounts.length <= 10^5. 0 <= pairCounts[i] <= 10^6.sum(pairCounts) > 0.- Each color has equally many left and right socks; drawing is without replacement.
More IMC Trading Phone Screen questions
- Election District Budget Allocation AnalysisPHONE SCREEN · Seen Aug 2026
- Uniform Variables: Smaller Below Larger SquaredPHONE SCREEN · Seen Mar 2026
- Combination Sum with Unlimited ReusePHONE SCREEN · Seen Dec 2025
- Valid Range of a Three-Outcome Probability ParameterPHONE SCREEN · Seen Dec 2025
- Expected Fishing CatchPHONE SCREEN · Seen Dec 2025
- Count Routes Through a City GridPHONE SCREEN · Seen Nov 2024
- Expected City Arrival and Return DaysPHONE SCREEN · Seen Nov 2024
- Stationary City Population SharesPHONE SCREEN · Seen Nov 2024
- Maximum Falling Path SumPHONE SCREEN · Seen Nov 2024
- Trading Profit Percentage ChangePHONE SCREEN · Seen Feb 2024
Similar questions at other companies
- Parking Fee CalculatorBreeze · PHONE SCREEN
- Merchant Payout Reserve CalculatorStripe · PHONE SCREENStripe interview questions
- Sqrt(x)LinkedIn · PHONE SCREENLinkedIn interview questions
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Circular Primes Below a LimitAmazon · PHONE SCREEN
- Palindrome NumberKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
- Streaming AverageXantium · PHONE SCREEN
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN