Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions articles/is-anagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl Solution {

### Time & Space Complexity

- Time complexity: $O(n + m)$
- Time complexity: $O(n)$
- Space complexity: $O(1)$ since we have at most $26$ different characters.

> Where $n$ is the length of string $s$ and $m$ is the length of string $t$.
Expand Down Expand Up @@ -603,7 +603,7 @@ impl Solution {

### Time & Space Complexity

- Time complexity: $O(n + m)$
- Time complexity: $O(n)$
- Space complexity: $O(1)$ since we have at most $26$ different characters.

> Where $n$ is the length of string $s$ and $m$ is the length of string $t$.
Expand All @@ -619,3 +619,7 @@ If two strings have different lengths, they cannot be anagrams. Skipping this ea
### Case Sensitivity Issues

When the problem specifies lowercase letters only (as in this problem), case sensitivity is not an issue. However, if the problem allows mixed case, forgetting to normalize to the same case (e.g., converting both strings to lowercase) will cause incorrect results where "Listen" and "Silent" would wrongly be considered non-anagrams.

### Time Complexity

If you first check the string lengths and only iterate a single string, the time complexity is $O(n)$, not $O(n + m)$.