Given two strings str1 and str2, write code to find out if all non-unique elements in str2 are in str1?
Problem Given two strings str1 and str2, write code to find out if all non-unique elements in str2 are in str1?
Solution Method 1 - Using hashset on str2 and boolean array or hashset on str2
Break down the problem into two tasks.
i) Finding the non-unique i.e. repeating elements in str 1. Hashing can be used for this purpose.
ii) Finding if all the characters hashed in the first string are available in the second string.
[Read More]