Check Two Strings are Anagrams or Not - Java Code

preview_player
Показать описание
Write a java program to check two strings are anagrams or not. In this tutorial, I have explained how to solve anagram problem in java using multiple approaches.

Рекомендации по теме
Комментарии
Автор

This is a gem. You need to be popular. Entire playlist of Interview Questions. Great job!!

harsimranization
Автор

easy way.Like this post important programs for interviews it is very helpful to everyone

Randoms
Автор

Another way...
private static boolean isAnagram(String s1, String s2)
{
int c1 = 0;
int c2 = 0;

if (s1.length() != s2.length())
return false;

for (int i = 0; i < s1.length(); i++)
{
c1 += s1.charAt(i);
c2 += s2.charAt(i);
}

if (c1 == c2)
return true;

return false;
}

brajrcr