Backend Engineer
Senior
programming
Implement a function that checks for possible anagrams of a given string by comparing it against a dictionary of words. The function should return all words in the dictionary that can be formed by rearranging the letters of the input string. ### Constraints: - 1 <= dictionary.length <= 1000 - 1 <= word.length <= 100 - The input string and all words consist of lowercase alphabets. ### Examples: 1. Input: dictionary = ["cat", "dog", "tac", "god", "act"], str = "act" Output: ["cat", "tac", "act"] 2. Input: dictionary = ["listen", "silent", "enlist", "inlets"], str = "listen" Output: ["listen", "silent", "enlist", "inlets"]
Suggested Answer