Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7166353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:23:59+00:00 2026-05-28T14:23:59+00:00

Given a set of strings (large set), and an input string, you need to

  • 0

Given a set of strings (large set), and an input string, you need to find all the anagrams of the input string efficiently. What data structure will you use. And using that, how will you find the anagrams?

Things that I have thought of are these:

  1. Using maps

    a) eliminate all words with more/less letters than the input.

    b) put the input characters in map

    c) Traverse the map for each string and see if all letters are present with their count.

  2. Using Tries

    a) Put all strings which have the right number of characters into a trie.

    b) traverse each branch and go deeper if the letter is contained in the input.

    c) if leaf reached the word is an anagram

Can anyone find a better solution?

Are there any problems that you find in the above approaches?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:23:59+00:00Added an answer on May 28, 2026 at 2:23 pm

    Build a frequency-map from each word and compare these maps.

    Pseudo code:

    class Word
    
      string word
      map<char, int> frequency
    
      Word(string w)
        word = w
        for char in word
          int count = frequency.get(char)
          if count == null
            count = 0
          count++
          frequency.put(char, count)
    
      boolean is_anagram_of(that)
        return this.frequency == that.frequency 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a set of words, we need to find the anagram words and display
Given a set of sixteen letters and an English dictionary file, need to find
What algorithm to use to check if a given string matches one of set
Given a string s , what is the fastest method to generate a set
Given this: Interface IBase {string X {get;set;}} Interface ISuper {string Y {get;set;}} class Base
given the following class ... public class Category { public string Name {get;set;} public
Given a set of phrases, i would like to filter the set of all
Given a set of strings, for example: EFgreen EFgrey EntireS1 EntireS2 J27RedP1 J27GreenP1 J27RedP2
Given a set of 100 different strings of equal length, how can you quantify
I need to convert a string into a set of arrays of a fixed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.