Function isAnagram

  • Check if 2 strings are anagrams of each other. Case-sensitive.

    Time complexity: O(n)

    Space complexity: O(n)

    Type Parameters

    • T

    Parameters

    • a: ArrayLike<T> & Iterable<T>

      First string to compare

    • b: ArrayLike<T> & Iterable<T>

      Second string to compare

    Returns boolean

    Whether the strings are anagrams of each other

    String

    isAnagram('abc', 'cba'); // true
    
    isAnagram('abc', 'Cba'); // false