Check if a string contains two non overlapping sub | C # implementation of the approach ; 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
using System ; class GFG { static bool isValid ( string s ) { if ( ( s . IndexOf ( " geek " ) != - 1 ) && ( s . IndexOf ( " keeg " , s . IndexOf ( " geek " ) + 4 ) != - 1 ) ) return true ; return false ; } public static void Main ( ) { string s = " geekeekeeg " ; if ( isValid ( s ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }