Accenture Coding Question | Anagrams | CodeWindow

Anagrams

An anagram is a word, phrase, or name formed by rearranging the letters of another word, phrase or name.

Write a function to check if the given two strings are anagrams or not. return “Yes” if they are anagrams otherwise return “No”.

Input specification:
Input1: The first string.
Input2: The second string.

Output Specification:
return “Yes” if they are anagrams otherwise return “No”.

Example 1:
Input 1: build
Input 2: dubli

Output: Yes
Explanation:
build and dubli are anagrams

Example 2:
Input 1: abcde
Input 2: bcdef

Output: No
Explanation:
abcde and bcdef are not anagrams

Solution in Python 3:

#https://codewindow.in
#join our telegram channel

n=input()
m=input()
count=0
l=len(m)
for i in n:
    if i in m:
        count=count+1
    else:
        pass
    
if count == l:
    print("Yes")
else:
    print("No")
    
# Telegram @codewindow

Output:

abc
aabbc
No
build
dubli
Yes
Recent Posts

Leave a Comment

Your email address will not be published. Required fields are marked *