Lexicographically smallest subsequence possible by removing a character from given string | C # program for the above approach ; Function to find the lexicographically smallest subsequence of length N - 1 ; Generate all subsequence of length N - 1 ; Store main value of string str ; Sort the vector ; Print first element of vector ; Driver Code ; Given string S ; Function Call
using System ; using System . Collections . Generic ; class GFG { static void firstSubsequence ( string s ) { List < string > allsubseq = new List < string > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { string k = " " ; for ( int j = 0 ; j < s . Length ; j ++ ) { if ( i != j ) { k += s [ j ] ; } } allsubseq . Add ( k ) ; } allsubseq . Sort ( ) ; Console . WriteLine ( allsubseq [ 0 ] ) ; } public static void Main ( ) { string S = " geeksforgeeks " ; firstSubsequence ( S ) ; } }