Function that print the desired array which satisfies the given conditions
function solve ( n , k ) { let mini = 0 ; let x1 = 1 ; let a = new Array ( k ) ; for ( let i = 1 ; i <= k ; i ++ ) { mini += x1 ; a [ i - 1 ] = x1 ; x1 += 1 ; }