Knowee
Questions
Features
Study Tools

Two strings, and , are called anagrams if they contain all the same characters in the same frequencies. For this challenge, the test is not case-sensitive. For example, the anagrams of CAT are CAT, ACT, tac, TCA, aTC, and CtA.Function DescriptionComplete the isAnagram function in the editor.isAnagram has the following parameters:string a: the first stringstring b: the second stringReturnsboolean: If and are case-insensitive anagrams, return true. Otherwise, return false.Input FormatThe first line contains a string .The second line contains a string .ConstraintsStrings and consist of English alphabetic characters.The comparison should NOT be case sensitive.

Question

Two strings, and , are called anagrams if they contain all the same characters in the same frequencies. For this challenge, the test is not case-sensitive. For example, the anagrams of CAT are CAT, ACT, tac, TCA, aTC, and CtA.Function DescriptionComplete the isAnagram function in the editor.isAnagram has the following parameters:string a: the first stringstring b: the second stringReturnsboolean: If and are case-insensitive anagrams, return true. Otherwise, return false.Input FormatThe first line contains a string .The second line contains a string .ConstraintsStrings and consist of English alphabetic characters.The comparison should NOT be case sensitive.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a Python solution for the problem:

def isAnagram(a, b):
    # convert both strings to lowercase
    a = a.lower()
    b = b.lower()

    # sort both strings
    a = ''.join(sorted(a))
    b = ''.join(sorted(b))

    # compare if both strings are equal
    if a == b:
        return True
    else:
        return False

This function works by first converting both input strings to lowercase, so the comparison is not case-sensitive. Then, it sorts the characters in both strings. If the sorted strings are equal, then the original strings are anagrams of each other, so the function returns True. Otherwise, the function returns False.

This problem has been solved

Similar Questions

Write a program to check two strings are anagram or not.

anagram functionProblem:define a recursive function to generate all Anagrams of a given stringTest Case 1:Enter a word: abcabcacbbacbcacabcbaTest Case 2:Enter a word: ababbaSample Test Cases

Given 2 strings, check if they are anagrams. An anagram is a rearrangement of the letters of one word to form another word. In other words, some permutations of string A must be the same as string B.Input FormatThe first line of input contains T - the number of test cases. It's followed by T lines, each line containing 2 space-separated strings.Output FormatFor each test case, print True/False, separated by a new line.Constraints10 points1 <= T <= 1001 <= len(S) <= 103'a' <= S[i] <= 'z'40 points1 <= T <= 1001 <= len(S) <= 105'a' <= S[i] <= 'z'ExampleInput4iamlordvoldemort tommarvoloriddleb hstop posthi heyOutputTrueFalseTrueFalse

Given a string S. the task is to determine if there exists another string that is an anagram of S.An anagram is a word or phrase formed by rearranging the letters of another word or phrase. For example "seekg" is an anagram of "geeks".Example 1:Input: S = "ab"Output: YESExplanation:The string "ba" is not identical to S and is an anagram of S

Write a program that figures out whether one string is an anagram of another string. The program should ignore white space and punctuation

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.