Back to course home
0% completed
Vote For New Content
Why O(1)?
Sujay
Jan 26, 2025
- We need to iterate through the entire string at least once to count the occurrences of each character. This step alone requires O(n) time, where n is the length of the string.
- In the worst case, we might have a string with n-1 repeating characters and a unique character at the end. This means we would need to scan through almost the entire string again to find that unique character
0
0
Comments
Comments
On this page