LeetCode 242 | Valid Anagram #100daysofcode #leetcodechallenge #javaprogramming

preview_player
Показать описание
An anagram is a word or phrase formed by rearranging the letters of another word or phrase, typically using all the original letters exactly once. For example, the word "listen" is an anagram of "silent".

1. Checks if the lengths of s and t are equal. If not, they cannot be anagrams, so it returns false.

2. Uses an integer array aer of size 26 to count occurrences of each character ('a' to 'z') in string s.
Decrements the corresponding counters for characters in string t.

3. Verifies if all counts in arr are zero after processing both strings. If so, returns true, indicating s and t are anagrams; otherwise, returns false.
Рекомендации по теме