531 questions
0
votes
1
answer
154
views
How to group anagrams using collections efficiently? [closed]
I'm working on a Java problem where I need to group words that are anagrams of each other. For instance, given the input array:
["eat", "tea", "tan", "ate", &...
1
vote
2
answers
70
views
Anagram check in Libreoffice Calc
How can I check in LibreOffice Calc whether two words have the same letters, i. e. are anagrams? Is this doable with the built-in functions?
Edit:
My idea is: convert the letters in both words to ...
0
votes
1
answer
103
views
Problem in solving valid anagram problem in leetcode
leetcode Problem 242
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
Read the following code as my approach to solve:
class Solution:
def isAnagram(self, s: ...
1
vote
1
answer
103
views
Construct list of possible sentences from given alphabet quota and wordlist.txt
I have wordlist.txt that separated by new line.
If I specify number of quotas to use for each alphabet for example
n: 1
e: 1
w: 1
b: 1
o: 2
k: 1
Remain alphabets quota is 0.
How to construct a ...
0
votes
0
answers
107
views
My anagram game will only play 5 letter words no matter what the player chooses in the drop down menu
I am having extreme difficulties in figuring out where my code is wrong in an anagram hunt vue.js app I am creating. At the beginning of the game, the player chooses the word length from a drop down ...
-2
votes
1
answer
210
views
Leetcode 242- Valid Anagram: Why is my code failing this test case?
Here's the prompt: Given two strings s and t, return true if t is an anagram of s, and false otherwise.
I tried to fix it by creating an if statement that would check if both Hashmaps are of the same ...
2
votes
2
answers
264
views
Most optimal solution O(1) to question: given a single word, return a list of anagrams present in the stream/list of words
I received this question in an interview, and coded out a solution, but it was not optimal.
Given a stream of words such as:
army, ramy, cat, eat, tea....
How can you store these words to support the ...
1
vote
1
answer
34
views
find anagram phase in dictionary
I want to find the anagram phase from the dictionary which checks it against the word mentioned by the users. A few examples, have shared ::
Example:
i/p --> Barbara Bush, o/p {"abash", &...
0
votes
1
answer
161
views
LeetCode's Valid Anagram challenge is not passing in all test cases but it works fine in my editor, why?
I tested my code on an online editor and it worked fine with all examples I tested, but it fails when I submit it to LeetCode. Why?
LeetCode submission result:
Wrong Answer
24 / 38 testcases passed
...
-2
votes
3
answers
959
views
Valid Anagram - Could Someone Please Explain why my code doesn't pass Example Case 2?
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all ...
0
votes
1
answer
51
views
Anagram finder in C displays correct and incorrect outcome?
I'm new to C and trying to make an anagram finder, but it doesn't work correctly and I'm not sure where I've gone wrong. It works by counting the number of letters in 2 different strings using 2 ...
2
votes
4
answers
2k
views
How to generate all anagrams of a given word in Python
I want to code a function in Python returning all possible anagrams of a word given. Only words of the English language are considered as such.
However, up to now, I only managed to generate all ...
2
votes
3
answers
119
views
Anagram function returns False for unknown reason in some words - Python
I've tried to create a function that returns True if two words are anagrams (have the same letters) to each other.
I realized that my counter counts to 13 but not sure what is the issue.
def ...
-1
votes
1
answer
80
views
How to create an anagram that prints an order of string in python using counter?
I am struggling to create an order of string using counter in python and my program is not printing an order of the given string below.
from collections import Counter, defaultdict
def ...
-6
votes
1
answer
319
views
Remove all anagrams from array
I need find and delete all anagrams from an array. All my attempts give ["bac","art"], but I need ["art"]
const deleteAnagrams = (arr) => {
let obj = {};
for (...
0
votes
0
answers
126
views
2273. Find Resultant Array After Removing Anagrams (Leetcode question)
In my code at line it is showing index -97 outofbound. Why it is showing that? Where is the problem with my code?
I don't understand why it is showing. What is wrong with my code or my logic?
class ...
-2
votes
2
answers
358
views
Check if any words in two lists are anagrams
I'm trying to write a function where it takes in two lists of any length, and returns True if list_1 has any words that are anagrams in list_2, and false if not.
For example:
words1 = [“dog”, “kitten”]...
0
votes
3
answers
167
views
Ruby Anagrams puzzle
i a m a begginner in ruby please i need directions in how to get the program to return a list containing "inlets"
Question: Given a word and a list of possible anagrams, select the correct ...
0
votes
1
answer
78
views
Finding anagrams of a specific word in a list
So, the problem is:
Given an array of m words and 1 other word, find all anagrams of that word in the array and print them.
Do y’all have any faster algorithm?:)
I’ve succesfully coded this one, but ...
0
votes
1
answer
75
views
Can someone please tell me why my code for Checking if two strings are anagram doesnt work [duplicate]
This is my code :
string_1 = input("Enter a string : ")
string_2 = input("Enter a second string : ")
a = sorted(string_1)
b = sorted(string_2)
print(a)
print(b)
if a in b and len(a)...
0
votes
0
answers
69
views
Return the largest group of Anagrams
This method should return the largest group of anagrams in the input array of words, in no particular order. It should return an empty array if there are no anagrams in the input array. This method ...
-1
votes
1
answer
128
views
Function to compare words to solve word game in Python
Im trying to find/write a function to compare two words in a Python program that solves a word puzzle game.
The goal of the game is to create as many word as possible using a set of 9 letters, the ...
0
votes
1
answer
374
views
Group Anagrams Recursion
I've been trying to find a solution to this problem however I can not seem to find out how to match my output with the expected output.
Here's the problem:
Given an array of strings strs, group the ...
2
votes
1
answer
226
views
Group Anagrams - LeetCode
Today I came across a solution for this problem:
https://leetcode.com/problems/group-anagrams/submissions/
The author used AbstractList to solve this problem. And the solution looks somewhat like this
...
0
votes
1
answer
108
views
What is wrong in finding anagram of string in my code? I did it using Hashmap in C programming
void anagram(char s[],char s1[]){ // Using Hashmap of size 26 (0 - 25)
int i,H[26]={0};
for(i=0;s[i]!='\0';i++){
H[s[i]-97]+=1;
}
for(i=0;s1[i]!='\0';i++){
H[...
-2
votes
1
answer
293
views
List of string to use in labels c#
First. I create a group of 5 labels using a for
for (byte fila = 0; fila < 5; fila++)
{
Label letras = new Label();
letras.Height = alto;
letras.Width = ...
1
vote
1
answer
70
views
How to find space complexity for anagram question
I use two 26 element arrays in my program.
What is the time and space complexity for this program to find if a string is an anagram of another?
int arr1[26] = { 0 };
int arr2[26] = { 0 };
for (char&...
0
votes
1
answer
2k
views
Check if two Strings are Anagrams Without using built-in features that require Import
I need to compare 2 strings and see if the number of every character each of them contain is the same.
Requirement:
Without using any packages or imports
My idea:
I want to check if a char from ...
1
vote
2
answers
1k
views
C# How to count how many anagrams are in a given string
I have to calculate how many anagrams are in a given word.
I have tried using factorial, permutations and using the posibilities for each letter in the word.
This is what I have done.
static int ...
0
votes
3
answers
306
views
To test if a word is an anagram and output a boolean
I am a complete beginner in programming and I am trying to a write code to check if a word is an anagram whose output must be a boolean.
When I run the code, the list of anagrams would include the ...
0
votes
3
answers
7k
views
Fun With Anagrams
Hi im trying to solve this riddle:
Given an array of strings, remove each string that is an anagram of an earlier string, then return the remaining array in sorted order.
Example
str = ['code', 'doce',...
-2
votes
1
answer
822
views
Using ASCII to find valid Anagram [closed]
Why doesn't this solution work for finding valid anagram?
26/36 test cases get passed in LeetCode.
class Solution {
public boolean isAnagram(String s, String t) {
int sASCII = 0, ...
2
votes
2
answers
158
views
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(...
3
votes
4
answers
848
views
Check whether two strings are anagrams
What is the most straightforward way to check whether two strings are anagrams? i.e. they share the same letters as well as number of occurrences of each these letters (and possibly other characters).
...
1
vote
0
answers
529
views
String anagrams grouping | Improvements and Analyzing time complexity
Following is editorial solution approach to Leetcode problem 49. Group Anagrams.
Problem statement
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
...
2
votes
1
answer
376
views
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 ...
0
votes
1
answer
113
views
How to account for amount of letters in a string [duplicate]
I want to write a function that finds anagrams. Anagrams are words that are written with the same characters. For example, "abba" and "baba".
I have gotten as far as writing a ...
0
votes
1
answer
322
views
Permutation using Recursion in Javascript
Through youtube, I've learned to obtain a multi-dimensional output of permutations using recursion, i.e anagrams with passing in an array of letters as an argument (i.e ['a', 'b', 'c']) but is there a ...
2
votes
1
answer
145
views
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 ...
1
vote
2
answers
160
views
How do i fix my code to check if two words are anagrams
I am writing code to check if two words are anagrams of each other. But when I run this program, it is telling me that "tacocat" and "tacocatt" are anagrams of each other and they ...
-1
votes
2
answers
1k
views
Comparing two string using XOR return true but the strings are different
I'm testing some ways to identify anagrams and I found a situation that got me off guard. I found out that it's possible to do using XOR so I was testing it using the XOR operator. Here's my code:
...
1
vote
1
answer
31
views
Anagram- Minimum number of char deletion required-'type' object is not subscriptable
The below code doesnot work. Why the map function is returning type error?
I have tried a many times. can someone give a proper reason for the below code?
n=26
string_array_1=[0]*n
string_array_2=[0]*...
1
vote
2
answers
559
views
find number of anagrams for one array of string in respect to another array of string
Suppose there are two arrays of strings. One array is named query, and the other one is named dictionary. For each string element of the query, you need to find how many anagrams of it exist among the ...
1
vote
1
answer
626
views
most efficient way to find all the anagrams of each word in a list
I have been trying to create a program that can find all the anagrams(in the list) for each word in the text file (which contain about ~370k words seperated by '\n').
I've already written the code in ...
-1
votes
3
answers
1k
views
Why do I get None in the output of this function?
I was asked to write a function to arrange a given number to get its maximum number.
The output is correct, but I keep getting None beside the rearranged number.
Obs: I don't want a new code. I want ...
1
vote
3
answers
87
views
is there any way to speed up the permuation creation for an anagramsolver?
I'm currently trying to make a very fast anagram solver, and right now it's bottlenecked by the creation of the permutations. is there another way to do the whole program or to optimize the ...
2
votes
1
answer
205
views
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, ...
0
votes
2
answers
295
views
Find anagrams in Groovy
The task I'm writing a script for is finding anagrams and then sorting words in the descending order of the number of anagrams found (or alphabetically when the number for two words is the same). My ...
2
votes
3
answers
525
views
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 ...
0
votes
2
answers
182
views
How do I use python recursion in this scenario?
"Write a recursive function called anagram(s) that returns a list of all the possible anagrams of the string, s." Can I get some guidance on how to tackle this question? I am new to ...