QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Check Anagram

Checks if two strings are anagrams, meaning they contain the same characters ignoring order, spaces and case sensitivity

  • string
  • anagram
  • compare
  • arrays
  • check

Code

def is_anagram(s1, s2):
    return sorted(s1) == sorted(s2)

Usage

System.out.println(isAnagram("listen", "silent")); // true
System.out.println(isAnagram("hello", "world"));   // false