Tap here to switch tabs
Problem
Submissions

Problem: Matchsticks to Square

Matchsticks to Square asks whether every stick in an integer array can be used exactly once, without breaking any, to form one square with four equal sides.

Statement

Given an integer array, matchsticks, where matchsticks[i] is the length of the ithith matchstick. Use every single matchstick to create a square. No stick should be broken, although they can be connected, and each matchstick can only be used once.

Return TRUE if we can make this square; otherwise, return FALSE.

Constraints:

  • 1≤1 \leq matchsticks.length ≤15\leq 15

  • 1≤1 \leq matchsticks[i] ≤103\leq 10^3

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Matchsticks to Square

Matchsticks to Square asks whether every stick in an integer array can be used exactly once, without breaking any, to form one square with four equal sides.

Statement

Given an integer array, matchsticks, where matchsticks[i] is the length of the ithith matchstick. Use every single matchstick to create a square. No stick should be broken, although they can be connected, and each matchstick can only be used once.

Return TRUE if we can make this square; otherwise, return FALSE.

Constraints:

  • 1≤1 \leq matchsticks.length ≤15\leq 15

  • 1≤1 \leq matchsticks[i] ≤103\leq 10^3