CamelCase Pattern Matching |  ; Concatenating all array elements using Aggregate function of LINQ putting semicolon as delimiter after each element ; Map to store the hashing of each words with every uppercase letter found ; temporary Variables ; Traversing through concatenated String ; Identifying if the current Character is CamelCase If so , then adding to map accordingly ; If pattern matches then print the corresponding mapped words ; If delimiter has reached then reseting temporary string also incrementing word position value ; If pattern matches then print the corresponding mapped words ; Driver 's Code ; Array of Words ; Pattern to be found ; Function call to find the words that match to the given pattern
using System ; using System . Collections . Generic ; using System . Linq ; public class GFG { public static void PrintMatchingCamelCase ( String [ ] arr , String pattern ) { String cctdString = arr . Aggregate ( ( i , j ) = > i + ' ; ' + j ) ; Dictionary < String , List < String > > map = new Dictionary < string , List < string > > ( ) ; int charPos = 0 ; int wordPos = 0 ; string strr = string . Empty ; for ( ; charPos < cctdString . Length ; charPos ++ ) { if ( cctdString [ charPos ] >= ' A ' && cctdString [ charPos ] <= ' Z ' ) { strr += cctdString [ charPos ] ; if ( map . ContainsKey ( strr ) ) { List < String > temp = new List < string > ( ) ; temp . AddRange ( map [ strr ] ) ; temp . Add ( arr [ wordPos ] ) ; map [ strr ] = temp ; } else { map . Add ( strr , new List < string > { arr [ wordPos ] } ) ; } } else if ( cctdString [ charPos ] == ' ; ' ) { wordPos ++ ; strr = string . Empty ; } } if ( map . ContainsKey ( pattern ) ) { foreach ( String word in map [ pattern ] ) { Console . WriteLine ( word ) ; } } else { Console . WriteLine ( " No ▁ Match ▁ Found " ) ; } } public static void Main ( String [ ] args ) { String [ ] arr = { " Hi " , " Hello " , " HelloWorld " , " HiTech " , " HiGeek " , " HiTechWorld " , " HiTechCity " , " HiTechLab " } ; String pattern = " HT " ; PrintMatchingCamelCase ( arr , pattern ) ; } }