Minimum length String with Sum of the alphabetical values of the characters equal to N | Function to find the minimum length ; Function to find the minimum length String ; Driver code
function minLength ( n ) { var ans = parseInt ( n / 26 ) ; if ( n % 26 != 0 ) ans ++ ; return ans ; } function minString ( n ) { var ans = parseInt ( n / 26 ) ; var res = " " ; while ( ans -- ) { res = res + " " ; } if ( n % 26 != 0 ) { res = res + String . fromCharCode ( ( n % 26 ) + 96 ) ; } return res ; } var n = 50 ; document . write ( minLength ( n ) + " " + minString ( n ) ) ;