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
def CamelCase ( words , pattern ) : NEW_LINE INDENT map = dict . fromkeys ( words , None ) ; NEW_LINE for i in range ( len ( words ) ) : NEW_LINE INDENT string = " " ; NEW_LINE l = len ( words [ i ] ) ; NEW_LINE for j in range ( l ) : NEW_LINE INDENT if ( words [ i ] [ j ] >= ' A ' and words [ i ] [ j ] <= ' Z ' ) : NEW_LINE INDENT string += words [ i ] [ j ] ; NEW_LINE if string not in map : NEW_LINE INDENT map [ string ] = [ words [ i ] ] NEW_LINE DEDENT elif map [ string ] is None : NEW_LINE INDENT map [ string ] = [ words [ i ] ] NEW_LINE DEDENT else : NEW_LINE INDENT map [ string ] . append ( words [ i ] ) ; NEW_LINE DEDENT DEDENT DEDENT DEDENT wordFound = False ; NEW_LINE for key , value in map . items ( ) : NEW_LINE INDENT if ( key == pattern ) : NEW_LINE INDENT wordFound = True ; NEW_LINE for itt in value : NEW_LINE INDENT print ( itt ) ; NEW_LINE DEDENT DEDENT DEDENT if ( not wordFound ) : NEW_LINE INDENT print ( " No ▁ match ▁ found " ) ; NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT words = [ " Hi " , " Hello " , " HelloWorld " , " HiTech " , " HiGeek " , " HiTechWorld " , " HiTechCity " , " HiTechLab " ] ; NEW_LINE pattern = " HT " ; NEW_LINE CamelCase ( words , pattern ) ; NEW_LINE DEDENT