You are given an array target of n integers. From a starting array arr consisting of n 1s, you may perform the following procedure:
- Let
xbe the sum of all elements currently in your array. - Choose index
isuch that0 <= i < nand set the value ofarrat indexitox. - You may repeat this procedure any number of times.
Return
Trueif it is possible to construct the target array fromarr, otherwise, returnFalse.
- An array of integers
target.
Input: target = [9, 3, 5]
Output: True
Explanation: [1, 1, 1] sum=3 -> [3, 1, 1] sum=5 -> [3, 5, 1] sum=9 -> [9, 5, 3] (permutation).