❤ Simple Java functional O(n) 4-liner. 🔥 Fastest HashMap solution (11ms)
Intuition\n Describe your first thoughts on how to solve this problem. \nThere must be solution on HashMap without if...else or loop operators.\n# Approach\n De
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThere must be solution on `HashMap` without `if`...`else` or loop operators.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n`HashMap.getOrDefault()` and streams.\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic boolean isAnagram(String s, String t) {\n\tMap<Integer, Integer> freqs = new HashMap<>();\n\ts.chars().forEach(ch -> freqs.put(ch, freqs.getOrDefault(ch, 0) + 1));\n\tt.chars().forEach(ch -> freqs.put(ch, freqs.getOrDefault(ch, 0) - 1));\n\treturn freqs.values().stream().allMatch(x -> x == 0);\n}\t\n```\n[Submission Detail](https://leetcode.com/submissions/detail/949746628)
['Hash Table', 'Data Stream', 'Java']