Ransom Note from Magazine using Hash table

Kidnapper kidnaps you and writes a ransom note. He does not write it with hand, as handwriting can put him in, so reaches to a magazine at table and creates ransom note. We need to find out given ransom string and magazine string, is it possible to create given ransom note. Kidnapper can use individual characters of words. We need to check if magazine string contains all characters and in equal or greater number, present in ransom note. You MUST use hashmap passed as an argument to solve the problem. Otherwise testcases will fail. Magazine : abcdefgab Note: baba Output: true Magazine: abcdedf Note: baba Output: false Your Answer.java should implement the following interface. import java.util.Map; public interface RansomNoteInterface { public boolean CheckIfRansomNoteCanbeFormed(String magazine, String note, Map<Character, Integer> inputMap); }

Answer

No comments:

Post a Comment