Find minimum number K such that sum of array after multiplication by K exceed S | Function to return the minimum value of k that satisfies the given condition ; store sum of array elements ; Calculate the sum after ; return minimum possible K ; Driver code
function findMinimumK ( a , n , S ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } return Math . ceil ( ( ( S + 1 ) * 1.0 ) / ( sum * 1.0 ) ) ; } let a = [ 10 , 7 , 8 , 10 , 12 , 19 ] ; let n = a . length ; let S = 200 ; document . write ( findMinimumK ( a , n , S ) ) ;