CamelCase Pattern Matching | C # to find CamelCase Pattern matching ; Function that prints the camel case pattern matching ; Map to store the hashing of each words with every uppercase letter found ; Traverse the words array that contains all the String ; Initialise str as empty ; length of String words [ i ] ; For every uppercase letter found map that uppercase to original words ; Traverse the map for pattern matching ; If pattern matches then print the corresponding mapped words ; If word not found print " No ▁ match ▁ found " ; Driver 's Code ; Pattern to be found ; Function call to find the words that match to the given pattern
using System ; using System . Collections . Generic ; class GFG { static void CamelCase ( List < String > words , String pattern ) { Dictionary < String , List < String > > map = new Dictionary < String , List < String > > ( ) ; for ( int i = 0 ; i < words . Count ; i ++ ) { String str = " " ; int l = words [ i ] . Length ; for ( int j = 0 ; j < l ; j ++ ) { if ( words [ i ] [ j ] >= ' A ' && words [ i ] [ j ] <= ' Z ' ) { str += words [ i ] [ j ] ; if ( map . ContainsKey ( str ) ) map [ str ] = list ( map [ str ] , words [ i ] ) ; else map . Add ( str , list ( null , words [ i ] ) ) ; } } } bool wordFound = false ; foreach ( KeyValuePair < String , List < String > > it in map ) { if ( it . Key . Equals ( pattern ) ) { wordFound = true ; foreach ( String s in it . Value ) Console . Write ( s + " STRNEWLINE " ) ; } } if ( ! wordFound ) { Console . Write ( " No ▁ match ▁ found " ) ; } } private static List < String > list ( List < String > list , String str ) { List < String > temp = new List < String > ( ) ; if ( list != null ) temp . AddRange ( list ) ; temp . Add ( str ) ; return temp ; } public static void Main ( String [ ] args ) { String [ ] arr = { " Hi " , " Hello " , " HelloWorld " , " HiTech " , " HiGeek " , " HiTechWorld " , " HiTechCity " , " HiTechLab " } ; List < String > words = new List < String > ( arr ) ; String pattern = " HT " ; CamelCase ( words , pattern ) ; } }