24 Game

Hard · Backtracking · about 30 minutes

Asked at Google, Uber, Microsoft, ByteDance, Bloomberg.

You have 4 cards, each a number from 1 to 9. Using +, -, *, / (real division) and parentheses, can you make an expression equal to 24 that uses every card exactly once? Unary minus and concatenating digits are not allowed. Return true or false.

Related guides