{"id":22513503,"url":"https://github.com/emahtab/valid-anagram","last_synced_at":"2026-03-19T23:02:43.050Z","repository":{"id":79525852,"uuid":"245816620","full_name":"eMahtab/valid-anagram","owner":"eMahtab","description":"Check if target string is anagram of source string","archived":false,"fork":false,"pushed_at":"2020-03-08T13:25:47.000Z","size":5,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T15:55:12.418Z","etag":null,"topics":["anagram","leetcode","problem-solving"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMahtab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-03-08T13:10:26.000Z","updated_at":"2022-11-13T23:16:29.000Z","dependencies_parsed_at":"2023-06-25T20:05:56.941Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/valid-anagram","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eMahtab/valid-anagram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fvalid-anagram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fvalid-anagram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fvalid-anagram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fvalid-anagram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/valid-anagram/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fvalid-anagram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29537848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T08:11:05.436Z","status":"ssl_error","status_checked_at":"2026-02-17T08:09:38.860Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anagram","leetcode","problem-solving"],"created_at":"2024-12-07T03:12:46.053Z","updated_at":"2026-02-17T08:35:45.947Z","avatar_url":"https://github.com/eMahtab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Valid Anagram\n# https://leetcode.com/problems/valid-anagram\n\nGiven two strings s and t , write a function to determine if t is an anagram of s.\n```\nExample 1:\n\nInput: s = \"anagram\", t = \"nagaram\"\nOutput: true\nExample 2:\n\nInput: s = \"rat\", t = \"car\"\nOutput: false\n```\n**Note:**\nYou may assume the string contains only lowercase alphabets.\n\n**Follow up:**\nWhat if the inputs contain unicode characters? How would you adapt your solution to such case?\n\n\n# Implementation 1 : Sorting\n\n```java\nclass Solution {\n    public boolean isAnagram(String s, String t) {\n        if (s.length() != t.length()) \n            return false;\n        \n        char[] str1 = s.toCharArray();\n        char[] str2 = t.toCharArray();\n        Arrays.sort(str1);\n        Arrays.sort(str2);\n        return Arrays.equals(str1, str2);\n    }\n}\n```\n\n# Implementation 2 : Hashing\n```java\nclass Solution {\n    public boolean isAnagram(String s, String t) {\n       if (s.length() != t.length()) \n         return false;\n      \n       int[] chars = new int[26];\n       for (int i = 0; i \u003c s.length(); i++) \n            chars[s.charAt(i) - 'a']++;\n      \n       for (int i = 0; i \u003c t.length(); i++) {\n            chars[t.charAt(i) - 'a']--;\n            if (chars[t.charAt(i) - 'a'] \u003c 0) {\n                return false;\n            }\n       }\n      return true;\n   }\n}\n```\n\n# Follow up :\nWhat if the inputs contain unicode characters? How would you adapt your solution to such case?\n\n**Answer :**\nUse a hash table instead of a fixed size counter. Imagine allocating a large size array to fit the entire range of unicode characters, which could go up to more than 1 million. A hash table is a more generic solution and could adapt to any range of characters.\n\n# References :\nhttps://leetcode.com/articles/valid-anagram\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fvalid-anagram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Fvalid-anagram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fvalid-anagram/lists"}