Check if there exists any sub | Function to check if there exists at least 1 sub - sequence in a string which is not palindrome ; use set to count number of distinct characters ; insert each character in set ; If there is more than 1 unique characters , return true ; Else , return false ; Driver code
function isAnyNotPalindrome ( s ) { var unique = new Set ( ) ; for ( var i = 0 ; i < s . length ; i ++ ) unique . add ( s [ i ] ) ; if ( unique . size > 1 ) return true ; else return false ; } var s = " " ; if ( isAnyNotPalindrome ( s ) ) document . write ( " " ) ; else document . write ( " " ) ;