Fair Cookie Splitting
Bill and Jack received cookies from their parents. Each cookie weighs either 1 gram or 2 grams. Now they want to divide all cookies among themselves fairly so that the total weight of Bill's cookies is equal to the total weight of Jack's cookies. Help them to check if they can do that. Note that cookies are not allowed to be cut in half.
You are given an array of integers where each integer represents the weight of a cookie. The weight can either be 1 gram or 2 grams. Return YES if all cookies can be divided into two sets with the same weight and NO in the opposite case.
Example 1
Input:
[1,1]
Output:
YES
Example 2
Input:
[1,2]
Output:
NO
main.cpp
C++
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme