Problem
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.
Example 1
- Input
- [1, 1, 2, 2, 2]
- Output
- True
- Why
- sides: 2, 2, 2, 1+1
Example 2
- Input
- [3, 3, 3, 3, 4]
- Output
- False
Constraints
1 <= matchsticks.length <= 151 <= matchsticks[i] <= 10^8