n starts out filled with ones. In one move you pick any element and overwrite it with the current sum of all elements (the element being replaced included). You may make as many moves as you like.
Given an array goal of length n, return True if the array of ones can be turned into exactly goal, and False otherwise.goal=[3, 1, 5] → True
[1, 1, 1] → the sum is 3 → [3, 1, 1] → the sum is 5 → [3, 1, 5].
goal=[2, 2] → False
From [1, 1] the first move gives [2, 1] or [1, 2], and every later move writes a value of at least 3. [2, 2] is out of reach.
goal=[1, 7] → True
goal=[3, 1, 5]
True
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.