Questions tagged [anagram]

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

531 questions
2
votes
2 answers

How can I get my desired output for this code? Time Limit Exceeded

code--> class Solution: def isAnagram(self, s1: str,t1: str) -> bool: flag=1 s = list(s1) t = list(t1) for i in range(len(s)): for j in range(len(s)): if s[i]==t[j]: …
2
votes
3 answers

anagram algorithm

Which is the best way of generating anagrams for a text(maximum 80 characters length). Example: Input: dog output dog dgo odg ogd gdo god I'm only thinking of a backtracking solution, but that will take a while if the text is longer. Another thought…
Dan Dinu
  • 32,492
  • 24
  • 78
  • 114
2
votes
1 answer

Python Wordle: determine if a given string matches to a correct anagram based on position score

Let assume I have a word word = abcde And a score board to show that the position of the characters in the word is correct or not in comparison to my desired output score = [T, F, F, T, F] Where T is for correct position, F is for incorrect. So we…
2
votes
1 answer

Anagram Javascript

Question with below code. If I'm decreasing the object value and when it comes to zero how it is satisfying this condition if(!obj1[letter]) because letter still exist in obj, its value is just going down. function validAnagram(a, b){ if(a.length…
2
votes
1 answer

For a given word calculate the number of possible anagrams

For a given word calculate the number of possible anagrams. The resulting words do not have to exist in the dictionary. Anagrams do not have to be repeated and anagrams do not have to be generated, only their number calculated. The last test is not…
user17693898
2
votes
3 answers

An algorithm reading N words and printing all anagrams

The original problem is here: Design a O(N log N) algorithm to read in a list of words and print out all anagrams. For example, the strings "comedian" and "demoniac" are anagrams of each other. Assume there are N words and each word contains at most…
faith
  • 121
  • 2
2
votes
4 answers

Anagram Code in Python - Compare dynamically generated strings to a txt file

I have written an Anagram solving program in Python. I wanted your opinion on whether I had gone about it right. Let me explain the logic: First, the user provides input of two words that he/she wants the single word anagram to be generated for (2…
Abhay Bhargav
  • 399
  • 1
  • 5
  • 15
2
votes
4 answers

What is the fastest way to search for anagrams?

I have a MySQL table with 267,751 words. I try to find the quickest way to find anagrams, without having to search through the entire table for each search, which would be incredibly inefficient. For the sake of clarity: An anagram is a word that…
2
votes
2 answers

Check how many character need to be deleted to make an anagram in Python

I wrote python code to check how many characters need to be deleted from two strings for them to become anagrams of each other. This is the problem statement "Given two strings, and , that may or may not be of the same length, determine the minimum…
2
votes
2 answers

Querying MySQL for anagrams

I have this script: $db = mysql_connect($hostname, $db_user, $db_password); mysql_select_db($database,$db) or die( "Unable to select database"); mysql_query("set names 'utf8'"); $wordy = "pate"; $query = mysql_query("SELECT DISTINCT * FROM…
faq
  • 2,965
  • 5
  • 27
  • 35
2
votes
2 answers

What is this code doing. Check two strings for anagrams

This code checks if two strings for an anagram. Can you please explain how it works what is it even doing. #include int t[256],i; int main(int c) { for(;c+3;) (i=getchar())>10?t[i]+=c:(c-=2); for(i=257;--i&&!t[i-1];); …
Neon
  • 41
  • 5
2
votes
0 answers

How do I make a function that returns a list of anagrams of words passed as a parameter, found in a pre-defined lexicon?

I am given a pre-defined lexicon saved in an external file, which is a list of words sorted from a to z. I am then asked to make a function, which takes a word as a parameter and returns a list of all the anagrams of that word found in the lexicon…
sbeve
  • 15
  • 5
2
votes
2 answers

Fast anagrams checker algorithm (HackerRank)

Problem: Given two arrays of strings, for every string in list (query), determine how many anagrams of it are in the other list (dictionary). It should return an array of integers. Example: query = ["a", "nark", "bs", "hack", "stair"] dictionary =…
Vicky
  • 73
  • 1
  • 1
  • 7
2
votes
2 answers

Finding Groups of Rearranged Strings from a txt With Strings on Seperate Lines

What I would like to do is take an input txt file of any length which looks like this bob joe obb oej and produce an output txt file which sorts groups of re-arranged words on a single line and alphabetically in an output txt file. bob obb joe…
tj tj
  • 35
  • 4
2
votes
3 answers

Find permutation of one string into other string program

Trying to make an program where it just check, if permutation of string s1 exists in string s2 or not. Created below program and it works for below test case. Input: s1 = "ab" s2 = "eidballl" Output: True Explanation: s2 contains one permutation…
Cod29
  • 265
  • 4
  • 14