Ideally you should try the steps 2 and 3 and come to SO when you are stuck with an issue and you can’t find an answer. For now, I will give you my approach – Just a pseudocode:
for(int i=0;i<arr.length;i++)
{
Map<Character,Integer> temp = hm;
for(Character c : arr[i].toCharArray())
{
if(!temp.containsKey(c) or temp[c]<=0)
break the loop;
else
temp[c]--;
}
if(end of arr[i] charArray)
answer.add(arr[i]);
}
0
solved Return words with characters [a,b,b,c]