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 code ; Array of words ; Pattern to be found ; Function call to find the words that match to the given pattern
#include <bits/stdc++.h> NEW_LINE using namespace std ; void PrintMatchingCamelCase ( vector < string > arr , string pattern ) { string cctdString = " " ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { cctdString += arr [ i ] ; if ( i != arr . size ( ) - 1 ) cctdString . push_back ( ' ; ' ) ; } unordered_map < string , vector < string > > maps ; int charPos = 0 ; int wordPos = 0 ; string strr = " " ; for ( ; charPos < cctdString . length ( ) ; charPos ++ ) { if ( cctdString [ charPos ] >= ' A ' && cctdString [ charPos ] <= ' Z ' ) { strr += cctdString [ charPos ] ; if ( maps . find ( strr ) != maps . end ( ) ) { vector < string > temp ; temp . insert ( temp . end ( ) , maps [ strr ] . begin ( ) , maps [ strr ] . end ( ) ) ; temp . push_back ( arr [ wordPos ] ) ; maps [ strr ] = temp ; } else { vector < string > vec = { arr [ wordPos ] } ; maps [ strr ] = vec ; } } else if ( cctdString [ charPos ] == ' ; ' ) { wordPos ++ ; strr = " " ; } } if ( maps . find ( pattern ) != maps . end ( ) ) { for ( int i = 0 ; i < maps [ pattern ] . size ( ) ; i ++ ) { cout << maps [ pattern ] [ i ] << endl ; } } else { cout << " No ▁ Match ▁ Found " << endl ; } } int main ( ) { vector < string > arr = { " Hi " , " Hello " , " HelloWorld " , " HiTech " , " HiGeek " , " HiTechWorld " , " HiTechCity " , " HiTechLab " } ; string pattern = " HT " ; PrintMatchingCamelCase ( arr , pattern ) ; }