Matchsticks to Square Transform

Asked at Bloomberg · Coding & Leetcode-style Questions · Difficulty: Medium

You have a box of matchsticks, and your task is to use these matchsticks to build a square. Each matchstick has a positive integer length and you need to find out if you can make a square using all of the matchsticks. You cannot break any matchstick, and you must use each matchstick exactly once. The total length of matchsticks should be divisible by 4. Return true if you can use all of the matchsticks to make a square, otherwise return false.

Loading the problem…