Check if a string contains two non overlapping sub | Function that returns true if s contains two non overlapping sub Strings " geek " and " keeg " ; If " geek " and " keeg " are both present in s without over - lapping and " keeg " starts after " geek " ends ; Driver Code
function isValid ( s ) { if ( ( s . indexOf ( " " ) != - 1 ) && ( s . indexOf ( " " , s . indexOf ( " " ) + 4 ) != - 1 ) ) return true ; return false ; } var s = " " ; if ( isValid ( s ) ) document . write ( " " ) ; else document . write ( " " ) ;