Practice 24 Game
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Use each of the four given cards exactly once to form an expression equal to 24. You may rearrange the cards and use addition, subtraction, multiplication, division and parentheses. Division is real-valued rather than integer division. Every operator combines two numbers: unary negation is forbidden, and adjacent card values cannot be concatenated into a new number. Return whether a valid expression exists.
Source: 24 Game on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
cards = [4,1,8,7]
true
# Example 2
cards = [1,2,1,2]
false
Constraints
Related LeetCode Problems
Practice more problems similar to 24 Game.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.