Weighted Prefix Search - GeeksforGeeks
Method 1: (Brute Force)
Read full article from Weighted Prefix Search - GeeksforGeeks
Given n strings and a weight associated with each string. The task is to find the maximum weight of string having the given prefix. Print “-1” if no string is present with given prefix.
Examples:
Input : s1 = "geeks", w1 = 15 s2 = "geeksfor", w2 = 30 s3 = "geeksforgeeks", w3 = 45 prefix = geek Output : 45 All the string contain the given prefix, but maximum weight of string is 45 among all.
Method 1: (Brute Force)
Check all the string for given prefix, if string contains the prefix, compare its weight with maximum value so far.