O69

Matchsticks to Square

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: BOOLEAN

Problem Statement & Objective

You are given an integer array matchsticks. Return True if you can make this array into a square by using all matchsticks.

Function Signature (Python)

makesquare(matchsticks: list[int]) -> bool

Input & Output Contract

Output Rule:True veya False.

System Constraints

1 <= kibritler.length <= 15
1 <= kibritler[i] <= 10^8

Example Execution Walkthrough

kibritler = [1, 1, 2, 2, 2] -> toplam 8, kenar 2 -> [1,1], [2], [2], [2] -> True
kibritler = [3, 3, 3, 3, 4] -> toplam 16, ancak 4 kenara bölünemez -> False

Example Test Scenarios (3)

Example 1
Input:[[1,1,2,2,2]]
Expected Output:true
Example 2
Input:[[3,3,3,3,4]]
Expected Output:false
Example 3: 4 Eşit Kibrit
Input:[[5,5,5,5]]
Expected Output:true
Loading Python Editor...
Input Parameters
[
  [
    1,
    1,
    2,
    2,
    2
  ]
]
Expected Output
true