You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Understand what the interviewer is asking for by using test cases and questions about the problem.
What if the string is empty?
In that case, the count would be 0.
P-lan
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Loop through the string, keeping track of both the current consecutive count and the maximum found so far.
1) If string is empty, return 0
2) Assume max count is 1 and current count is 1
3) For each character in the string (skipping the first)
a) If the character matches the one before it
i) add 1 to current
ii) if current > max, update max
b) If no match, reset current to 1
4) Return max