Tap here to switch tabs
Problem
Submissions

Problem: 24 Game

med
30 min
Try to solve the 24 Game problem.

Statement

You are given an integer array cards of length 44. You want to evaluate whether you can arrange the integers with the four basic arithmetic operations (++, −-, ∗*, //) and parentheses such that the resulting expression evaluates to 2424.

Return true if you can obtain 2424 from cards, and false otherwise.

Note:

  • The division operator (//) represents real division, not integer division.

  • Every operation must be performed between two numbers. You cannot concatenate numbers together (for instance, if cards contains 11 and 22, you cannot form 1212).

  • You must use all 44 integers, and each integer must be used exactly once.

Constraints:

  • cards.length =4= 4

  • 1≤1 \leq cards[i] ≤9\leq 9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: 24 Game

med
30 min
Try to solve the 24 Game problem.

Statement

You are given an integer array cards of length 44. You want to evaluate whether you can arrange the integers with the four basic arithmetic operations (++, −-, ∗*, //) and parentheses such that the resulting expression evaluates to 2424.

Return true if you can obtain 2424 from cards, and false otherwise.

Note:

  • The division operator (//) represents real division, not integer division.

  • Every operation must be performed between two numbers. You cannot concatenate numbers together (for instance, if cards contains 11 and 22, you cannot form 1212).

  • You must use all 44 integers, and each integer must be used exactly once.

Constraints:

  • cards.length =4= 4

  • 1≤1 \leq cards[i] ≤9\leq 9