Ctrl K

Pairing Chips from Three Piles

Medium
Three piles of chips lie on the table: red red chips, green green chips and blue blue chips. In one round you take one chip from each of two different non-empty piles and remove both. The game ends when fewer than two piles are non-empty. Return the largest number of rounds you can play.
Example 1
red=3, green=3, blue=3 → 4

There are 9 chips and each round uses two, so at most 4 rounds. Four is reachable: say red+green, red+blue, green+blue, red+green, leaving a single blue chip.

Example 2
red=1, green=2, blue=10 → 3

Every round needs at least one non-blue chip and there are only 3 of them. Pair each with a blue chip for 3 rounds.

Constraints
  • 1 ≤ red, green, blue ≤ 10⁵
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPrices That Fade With Each Sale MediumSame Prizes, Different Tastes MediumA Crew Levels a Hill MediumSparse Ones in a Grid HardCloning Builders Hard
loading Python…
Input
red=3, green=3, blue=3
Expected
4

Run checks the first 3 tests in your browser. Submit checks all 88 tests on the server, hidden ones included.