2dbi

Three Mislabelled Jars Puzzle

viaLeetCode

Problem Three jars: one all oranges, one all apples, one a mix. ALL THREE labels are wrong. What is the minimum number of fruit draws to relabel every jar correctly?

Input / Output

  • A reasoning puzzle: state the answer and prove both sufficiency and necessity.

Example

  • Answer: 1 draw.

Expected approach

  • Draw from the jar labelled "mix". Since every label is wrong, that jar is pure — the drawn fruit names it (say, orange). The jar labelled "apples" can't hold apples (wrong label) and can't be the oranges jar (taken), so it's the mix; the remaining jar is apples. Sufficiency shown; necessity: zero draws leaves multiple consistent assignments, so 1 is minimal. The evaluated skill is exploiting the "all labels wrong" constraint and arguing the lower bound, not just recalling "1".
Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account