Find a string such that every character is lexicographically greater than its immediate next character | Function that prints the required string ; Find modulus with 26 ; Print extra characters required ; Print the given reverse string countOfStr times ; Driver Code ; Initialize a string in reverse order
function printString ( n , str ) { var str2 = " " ; var extraChar = n % 26 ; if ( extraChar >= 1 ) { for ( var i = 26 - ( extraChar + 1 ) ; i <= 25 ; i ++ ) str2 += str [ i ] ; } var countOfStr = parseInt ( n / 26 ) ; for ( var i = 1 ; i <= countOfStr ; i ++ ) { for ( var j = 0 ; j < 26 ; j ++ ) str2 += str [ j ] ; } return str2 ; } var n = 30 ; var str = " " ; document . write ( printString ( n , str ) ) ;