Is Anagram - Easy Problems - Solution to Toph.co Online Judge Problem

Is Anagram

Limits 1s, 512 MB

An anagram is a word formed by rearranging the letters of another word.
The words “listen” and “silent” has the same letters in them appearing the same number of times. This makes these two words anagram to each other.
Given two words, you need to determine if they are anagrams of each other.

Input

The input will contain two strings A (Length of A) and B (Length of B < 100), one per line.
A and B will contain lowercase alphabets only.

Output

Print “Yes” if the two words are anagrams of each other, otherwise “No”.

#include<stdio.h>
#include<string.h>

int main()
{
    int i,j,flag=0;
    char str1[100],str2[100];
    gets(str1);
    gets(str2);

    for(i=0;i<strlen(str1);i++)
    {
        flag=0;
        for(j=0;j<strlen(str2);j++)
        {
            if(str1[i]==str2[j])
            {
                flag=1;
                break;
            }

        }
        if(flag==0)
        break;
    }
if(flag==0)
        printf("No");
else
    printf("Yes");


}