Questions tagged [anagram]

A word, phrase, or name formed by rearranging the letters of another, such as cinema, formed from iceman.

531 questions
3
votes
7 answers

Find group of strings that are anagrams

This question refers to this problem on lintcode. I have a working solution, but it takes too long for the huge testcase. I am wondering how can it be improved? Maybe I can decrease the number of comparisons I make in the outer loop. class…
Wajahat
  • 1,593
  • 3
  • 20
  • 47
3
votes
3 answers

C# Anagram Checker With LinkedList

I'm trying to check if two words are anagram and trying to do this with LinkedList.To do that,first,I created a class named LinkedList: class LinkedList { private Node head; private int count; public LinkedList() { …
Fethi Tekyaygil
  • 355
  • 2
  • 15
3
votes
3 answers

Check to see if two strings are anagrams of each other in JavaScript. What logic is used here?

Can someone help explain the logic used in the JavaScript code here? The code below checks to see if two strings are anagrams of each other, but I don't understand the method being used to check the string. Thanks.
kb2321
  • 31
  • 5
3
votes
3 answers

why doesn't this code work for anagram checking?

I'm trying make an anagram check in javascript. For simplicity, assume that the function below only takes lowercase strings without any spacing/numbers/symbols. Why doesn't the code below work? var anagram = function(string1, string2) { var…
d1du
  • 296
  • 1
  • 3
  • 12
3
votes
2 answers

Check whether two String's are anagram

I wrote a method for checking whether two Strings are anagram or not. The method is returning true even if the words are not anagram. I don't see any bug in the code, any ideas how can I improve ? The method is as following, public static boolean…
Arefe
  • 1,029
  • 5
  • 16
  • 30
3
votes
5 answers

Check Permutation of two strings

I do have a problem, that I am trying to use the most efficient way to solve it. "Given two strings, find out if the two strings are permutation of each other." I do know the straightforward ways to do it (i.e sorting the two strings) etc. I want…
Phrixus
  • 1,209
  • 2
  • 19
  • 36
3
votes
1 answer

Valid anagrams code - fails for one case out of 32 cases. passes for 31 cases

I tried writing a small code for anagrams and I wrote the below onw. String s = "anagram"; String t = "nagara"; Map map1 = new HashMap(); Map map2 = new HashMap(); …
user2868864
  • 165
  • 2
  • 12
3
votes
2 answers

Anagram Algorithm Clarification

I am new to this forum and wanted to ask a question. I have seen multiple people asking questions on anagrams but my question is related to this specific algorithm. I saw this algorithm which uses recursion technique for generating anagrams but a…
Shyna
  • 145
  • 2
  • 10
3
votes
1 answer

Unique hash for same set of characters given in any order?

Consider this example of finding anagrams aabc abca They both are anagrams, I am looking for a way so that their hash generated by characters is same and unique. The uniqueness is important so that no two different string aabc and xyaq generate…
daydreamer
  • 87,243
  • 191
  • 450
  • 722
3
votes
5 answers

Comparing two arrays containing strings for anagrams in Ruby

Forgive me if my code is off. I've still got my head in Ruby on Rails which seems to have subtle differences that are coming out as I learn more "just Ruby," although to be fair I'm not sure my code would pass muster in a Ruby on Rails format. I…
DanielNordby
  • 569
  • 2
  • 6
  • 20
3
votes
1 answer

Number of possible palindrome anagrams for a given word

I have to find No. of palindrome anagrams are possible for a given word. Suppose the word is aaabbbb.My approach is Prepare a hash map that contains no. of time each letter is appearing For my example it will be a--->3 b--->4 If length of…
Roshan
  • 2,144
  • 2
  • 16
  • 28
3
votes
3 answers

Anagram solver in C++

I am working on a project for school and I am stuck on what I believe is just a small part but I cant figure it out. Here is what I have so far: #include #include #include #include #include #include…
Arob33
  • 55
  • 1
  • 6
3
votes
1 answer

Python Anagrams recursion

I have this code: mylist = open('sortedwords.txt') txt = mylist.read() mylist = txt.split() stuff = input('Type a word here: ') def removeletters (word, Analysis): for char in range (len(Analysis)): if Analysis [char] in word: …
user3040579
  • 31
  • 1
  • 3
3
votes
1 answer

Anagram Index Calculation

Given an input string up to 25 characters long consisting of characters A-Z, output its index in the alphabetically sorted list of all possible anagrams of the input string. Input string is not case sensitive. Input characters can be repeated. The…
user2694688
3
votes
18 answers

Check whether two strings are anagrams using C++

The program below I came up with for checking whether two strings are anagrams. Its working fine for small string but for larger strings ( i tried : listened , enlisted ) Its giving me a 'no !' Help ! #include
user2688416
  • 49
  • 1
  • 1
  • 3