Note : Default values in visited are false
var visited = new [ 26 ] ; for ( var k = i ; k <= j ; k ++ ) { if ( visited [ str . charAt ( k ) - ' ' ] == true ) return false ; visited [ str . charAt ( k ) - ' ' ] = true ; } return true ; }