-
Notifications
You must be signed in to change notification settings - Fork 20
Solution #1358 - Mridul/Edited - 11/03/2025 #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
## Code Breakdown | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh where's the code breakdown
Time complexity: O(n) | ||
Space complexity: O(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kindly explain the Time & Space Complexity as well
freq.put(s.charAt(i), freq.getOrDefault(s.charAt(i), 0) + 1); | ||
|
||
while (freq.size() == 3) { | ||
cnt += s.length() - i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to use a more meaningful variable name. This is fine here, but it would be better to call it count rather than cnt. It's a small pointer and can be ignored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kindly make the required changes
added solution.java and explanation.md with the time and space complexities