Get K | Utility function ; Function to return the K - th letter from new String . ; finding size = length of new string S ' ; get the K - th letter ; Driver program
function isAlphaNumeric ( str ) { var code , i , len ; for ( i = 0 , len = str . length ; i < len ; i ++ ) { code = str . charCodeAt ( i ) ; return false ; } } return true ; } ; function K_thletter ( S , K ) { var N = S . length ; var size = 0 ; for ( var i = 0 ; i < N ; ++ i ) { if ( Number . isInteger ( parseInt ( S [ i ] ) ) ) size = size * ( S [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; else size += 1 ; } for ( var i = N - 1 ; i >= 0 ; -- i ) { K %= size ; if ( K == 0 && isAlphaNumeric ( S [ i ] ) ) return " " + S [ i ] ; if ( Number . isInteger ( parseInt ( S [ i ] ) ) ) size = size / ( S [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; else size -= 1 ; } } var S = " " ; var K = 15 ; document . write ( K_thletter ( S , K ) ) ;