text: Minimize sum of smallest elements from K subsequences of length L | Function to find the minimum sum ; Sort the array ; Calculate sum of smallest K elements ; Return the sum ; Driver Code
code: function findMinSum ( arr , K , L , size ) { if ( K * L > size ) return - 1 ; let minsum = 0 ; arr . sort ( ( a , b ) => a - b ) ; for ( let i = 0 ; i < K ; i ++ ) minsum += arr [ i ] ; return minsum ; } let arr = [ 2 , 15 , 5 , 1 , 35 , 16 , 67 , 10 ] ; let K = 3 ; let L = 2 ; let length = arr . length ; document . write ( findMinSum ( arr , K , L , length ) ) ;