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 6626609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:54:44+00:00 2026-05-25T21:54:44+00:00

Given a string value of arbitrary length, you’re supposed to determine the frequency of

  • 0

Given a string value of arbitrary length, you’re supposed to determine the frequency of words which are anagrams of each other.

public static Map<String, Integer> generateAnagramFrequency(String str)
{ ... }

For example: if the string is “find art in a rat for cart and dna trac”
your output should be a map:
find -> 1
art -> 2
in -> 1
a -> 1
cart -> 2
and -> 2

The keys should be the first occurrence of the word, and the number is the number of anagrams of that word, including itself.

The solution i came up with so for is to sort all the words and compare each character from both strings till the end of either strings. It would be O(logn). I am looking for some other efficient method which doesn’t change the 2 strings being compared. Thanks.

  • 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-25T21:54:45+00:00Added an answer on May 25, 2026 at 9:54 pm

    I’ve written a JavaScript implementation of creation a n-gram (word analysis), at Extract keyphrases from text (1-4 word ngrams).

    This function can easily be altered to analyse the frequency of anagrams:
    Replace s = text[i]; by s = text[i].sort(), so that the order of characters doesn’t matter any more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to determine the display length of a given string (in
Given an action like: public ActionResult DoStuff([CustomAttribute(foo)]string value) { // ... } Is there
given an xml string like this: <some><nested><xml>value</xml></nested></some> what's the best option (using ruby) to
Given a potentially huge integer value (in C# string format), I want to be
i need Enumarable value from below class but give error public static Enumerable LoadDataByName(string
consider the following two pieces of code: public static Time Parse(string value) { string
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
Given the string value: ?*8 100 0 I'd like the value between the two
I want to find integer value from a string. For example, given a String
Given the following URL: domain.com/page.aspx?id=123 How can I sanitize that query string value when

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.