Check if two same sub | C # Pprogram to Check if similar subsequences exist or not ; Function to check if similar subsequences occur in a string or not ; iterate and count the frequency ; counting frequency of the letters ; check if frequency is more than once of any character ; Driver Code
using System ; using System . Collections . Generic ; class GFG { static bool check ( String s , int l ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < l ; i ++ ) { freq [ s [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] >= 2 ) return true ; } return false ; } public static void Main ( String [ ] args ) { String s = " geeksforgeeks " ; int l = s . Length ; if ( check ( s , l ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }