Open cogitable[bot] opened 2 years ago
nonConstructibleChange ts typescript e javascript o sort padrão é gramatical. Por isso tem que se colocar o parametro
array.sort((x,y) => x-y )
export function nonConstructibleChange(coins: number[]) { coins.sort((x,y) => x-y) let currentChangeCreated = 0 for (let i=0; i < coins.length; i++){ if (coins[i] > currentChangeCreated + 1){ return currentChangeCreated + 1 } currentChangeCreated += coins[i] } return currentChangeCreated + 1 }
Mention in AlgoExpert #194