Skip to content

183 - Anagrams - typescript #186

Open
@jsartisan

Description

@jsartisan

index.ts

export function areAnagrams(s: string, t: string): boolean {
  if (s.length !== t.length) {
    return false;
  }

  const sortedS = sortString(s);
  const sortedT = sortString(t);

  return sortedS === sortedT;
}

function sortString(str: string): string {
  return str.split('').sort().join('');
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      183 - Anagrams - typescript · Issue #186 · jsartisan/frontend-challenges