Matchsticks to Square
MediumBacktracking
Decode it first. Clues, constraints, pattern and plan before any code.You have matchsticks of the lengths in matchsticks. Decide whether you can make a square using every matchstick exactly once. Sticks can be joined end to end but not broken.
[1, 1, 2, 2, 2] → True (sides: 2, 2, 2, 1+1)
[3, 3, 3, 3, 4] → FalseConstraints
1 <= matchsticks.length <= 151 <= matchsticks[i] <= 10^8