A word, phrase, or name formed by rearranging the letters of another, such as cinema, formed from iceman.
Questions tagged [anagram]
531 questions
-1
votes
2 answers
code performance of my code
import java.util.Scanner;
class same
{static void anagram(String s1,String s2)
{int p=0;
char[] c1=s1.toCharArray();
char[] c2=s2.toCharArray();
if(s1.length()!=s2.length())
{
…

anuj
- 31
- 2
-1
votes
2 answers
I get a time exceeded for grouping words in anagrams , is there any other way
class Solution:
# @param {string[]} strs
# @return {string[][]}
def isAnagram(self, s, t):
s1 = [];s2 = []
s1[:0] = s
s2[:0] = t
s1.sort();s2.sort()
if s1 == s2:
return True
else:
return False
def…

Shashank Shekhar
- 3
- 2
-1
votes
2 answers
Check if string is anagram of palindrome
My question is:
How do you check if a given string is the anagram of a palindrome?
I found some solutions in Python on the internet, but I'm not sure how can I check this yet. I was thinking about converting the strig to a char [], and then get the…

Marian Ene
- 615
- 2
- 7
- 21
-1
votes
2 answers
Determine if two words are anagrams
I recently took a quiz asking me to determine if elements in an array were anagrams. I completed an implementation, but upon running their tests, I only passed 1 of 5 test cases. The problem is, they wouldn't allow me to see what the tests were, so…

arc4randall
- 3,275
- 3
- 27
- 40
-1
votes
7 answers
Anagram java code
Can someone explain to me how the marked lines below work? What do they do exactly?
public class GrammerUtils {
public static void main(String args[]) {
System.out.print(isAnagram("teacher", "cheater"));
}
public…

Namenone
- 344
- 2
- 5
- 19
-1
votes
1 answer
Anagram Checker Explanation
im a first year programmer and i was wondering what this code extract does. Its part of a main which does a check to see if 2 words are anagrams of one another. Im not fullly sure what this represents though.
for(int x = 0; x < array.length;…

Chilli
- 603
- 1
- 6
- 8
-2
votes
0 answers
Why does my code run into a EXCX_BAD_ACCESS error in Xcode when testing for longer words when it works fine for smaller words?
#include
#include
#include
#include
#include
#include
using namespace std;
const int MAXRESULTS = 20; // Max matches that can be found
const int MAXDICTWORDS = 30000; // Max words that…
-2
votes
2 answers
How to find anagram frequency in a string?
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 generateAnagramFrequency(String str)
{ ... }
For example: if the string is "find art…

Venugopal Madathil
- 2,031
- 3
- 34
- 44
-2
votes
3 answers
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 the original letters exactly once.
Example…
-2
votes
2 answers
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”]
words2 = [“tiger”, “god”]
return True, as “dog”…

mlenthusiast
- 1,094
- 1
- 12
- 34
-2
votes
1 answer
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 = ancho;
letras.BackColor = Color.Blue;
…
-2
votes
1 answer
Giving Wrong output
I was trying Leetcode problem https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram/
It is to return minimum number of letters that needs to be changed to make the two strings anagrams. However when pass a string…

Karan Nayyar
- 57
- 1
- 1
- 8
-2
votes
1 answer
can anyone please tell me what's wrong with my c++ code?
question: Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] and its permutations (or anagrams) in txt[]. You may assume that n >…

bunny bugs
- 35
- 7
-2
votes
2 answers
Checking if two strings are anagram
Problem is given two strings, check whether two given strings are anagram of each other or not. An anagram of a string is another string that contains same characters, only the order of characters can be different. For example, “act” and “tac” are…
user9083520
-2
votes
1 answer
Minimum number of manipulations for anagrams
Given a string, we must split it into two contiguous substrings, then determine the minimum number of characters to change to make the two substrings into anagrams of one another.
def anagram(s):
flag = 0
if len(s)%2 != 0: return -1
…

srkdb
- 775
- 3
- 15
- 28