Sale
Summer Offer: $190/yr $99/yr
00 : 00 : 00 : 00
Get this deal
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

Trusted by 100+ professionals preparing for interviews

Trusted by 100+ professionals 50+ Company Question Banks 5+ Supported Languages

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

Get Started Free
Link copied to clipboard