Giving a dictionary and a string ‘str’, find the longest string in
dictionary which can be formed by deleting some characters of the given
‘str’.
Input : dict = {"ale", "apple", "monkey", "plea"} str = "abpcplea"
Output : apple
Input : dict = {"pintu", "geeksfor", "geeksgeeks", " forgeek"}
str = "geeksforgeeks"
Output : geeksgeeks
3. Find subarray with given sum | Set 1 (Non-negative Numbers).
- Given an unsorted array of nonnegative integers, find a continuous subarray which adds to a given number.
Input: arr[] = {1, 4, 20, 3, 10, 5}, sum = 33
Ouptut: Sum found between indexes 2 and 4
Sum of elements between indices
2 and 4 is 20 + 3 + 10 = 33
Input: arr[] = {1, 4, 0, 0, 3, 10, 5}, sum = 7 Ouptut: Sum found between indexes 1 and 4
Sum of elements between indices
1 and 4 is 4 + 0 + 0 + 3 = 7
Input: arr[] = {1, 4}, sum = 0 Output: No subarray found
There is no subarray with 0 sum