Function isAnagram

  • Category

    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

    Example

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

    Example

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