Questions tagged [anagram]

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

470 questions
8
votes
2 answers

Ruby way to group anagrams in string array

I implemented a function to group anagrams. In a nutshell: input: ['cars', 'for', 'potatoes', 'racs', 'four','scar', 'creams', scream'] output: [["cars", "racs", "scar"], ["four"], ["for"], ["potatoes"],["creams", "scream"]] I would like to know if…
alexandrecosta
  • 2,908
  • 2
  • 14
  • 15
8
votes
5 answers

How Can I Speed Up This Anagram Algorithm

I am making a mobile app to find anagrams and partial matches. Mobile is important because there is not a whole lot of computational power, and efficiency is key. The algorithm takes any number of letters, including repeats, and finds the longest…
coneybeare
  • 33,248
  • 21
  • 128
  • 182
8
votes
5 answers

Anagram algorithm with minimum complexity

I recently was asked to design an algorithm that checks if two strings are anagrams of one another. My goal was to minimize space and time complexity, so I came up with this algorithm: Create an array of 26 elements, each initialized to…
garima
  • 4,934
  • 10
  • 41
  • 76
8
votes
4 answers

All anagrams in a File

Source : Microsoft Interview Question We are given a File containing words.We need to determine all the Anagrams Present in it . Can someone suggest most optimal algorithm to do this. Only way i know is Sorting all the words,then checking .
Spandan
  • 2,058
  • 4
  • 21
  • 35
8
votes
5 answers

A possible algorithm for determining whether two strings are anagrams of one another?

I have this idea (using C language) for checking whether two strings formed from ASCII letters are anagrams of one another: Check if the strings are the same length. Check if the sum of the ASCII values of all chars is the same for both…
Alex Goltser
  • 99
  • 1
  • 4
7
votes
10 answers

What is an easy way to tell if a list of words are anagrams of each other?

How would you list words that are anagrams of each other? I was asked this question when I applied for my current job. orchestra can be rearranged into carthorse with all original letters used exactly once therefore the words are anagrams of each…
jqs
  • 159
  • 3
  • 12
7
votes
3 answers

How to write an anagram generator in pure C# and .Net framework

I would like to generate anagram output of a given string without the help of any external libraries such as Google anagram algorithms helper. Example: Input string = "GOD" Output list should look like the following one: G O D GO GD OD OG DG DO…
manu
  • 1,616
  • 3
  • 24
  • 31
7
votes
5 answers

Checking if two Strings are anagram of each other using basic Java

I am writing following code in java Netbeans which is working quite good for normal anagrams. But if the two text fields contain words which contain repetitive letters, then the code fail to work. What may be the problem and how can I solve it? I am…
Prakhar Londhe
  • 1,226
  • 1
  • 10
  • 22
7
votes
5 answers

Finding anagaram(s) of dictionary words

How can I take an input word (or sequence of letters) and output a word from a dictionary that contains exactly those letters? Does java has an English dictionary class (list of words) that I can use, or are there open source implementations of…
Jony
  • 6,352
  • 19
  • 56
  • 69
6
votes
5 answers

Given a string array, return all groups of strings that are anagrams

Given a string array, return all groups of strings that are anagrams. My solutions: For each string word in the array, sort it O(m lg m), m is the average length of a word. Build up a hash Table < string, list >. Put the sorted word into the hash…
user1002288
  • 4,502
  • 9
  • 45
  • 76
6
votes
3 answers

Ruby - Anagram Codes

We have an array of words here: words = ['demo', 'none', 'tied', 'evil', 'dome', 'mode', 'live', 'fowl', 'veil', 'wolf', 'diet', 'vile', 'edit', 'tide', 'flow', 'neon'] My teacher wrote a program that prints out groups of words…
user6925364
6
votes
11 answers

Swift Anagram checker

I am attempting to build an anagram checker for swift. This is my code. In case you don't know an anagram checker checks if two strings have the same characters in them but, order does not matter. func checkForAnagram(#firstString: String,…
Cody Weaver
  • 4,356
  • 8
  • 29
  • 50
6
votes
4 answers

Check my anagram code from a job interview in the past

Had the following as an interview question a while ago and choked so bad on basic syntax that I failed to advance (once the adrenalin kicks in, coding goes out the window.) Given a list of string, return a list of sets of strings that are anagrams…
Michael Dorgan
  • 12,091
  • 2
  • 27
  • 61
6
votes
4 answers

Fast anagram solving

Given two strings, I would like to determine whether or not they are anagrams of one another. Here is the solution that I came up with: # output messages def anagram puts "Anagram!" exit end def not_anagram puts "Not an anagram!" …
Hunter McMillen
  • 52,839
  • 21
  • 105
  • 154
6
votes
5 answers

get list of anagrams from a dictionary

Basically, Anagrams are like permutation of string.E.g stack ,sackt ,stakc all are anagrams of stack (thought above words aren't meaningful). Anyways you could have understood what I basically meant. Now, I want a list of anagrams given million…
vijay
  • 1,932
  • 3
  • 16
  • 32
1
2
3
31 32