Longest Consecutive Character Sequence: Interview with a FAANG Engineer

Longest Consecutive Character Sequence

Watch someone solve the longest consecutive character sequence problem in an interview with a FAANG engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.

Interview Summary

Problem type
Longest Consecutive Character Sequence
Interview question
Given an unsorted list of lowercase letter characters, where duplicates may appear and order does not matter, find the length of the longest sequence of alphabetically consecutive characters. For example, given the input [D, A, C, B, F], the answer is 4, because A, B, C, D form the longest consecutive sequence. The follow-up asks whether the O(n log n) sorting-based approach can be improved, and the discussion arrives at an O(n) solution using a set-based lookup strategy.

Interview Feedback

Feedback about Pseudo Centaur (the interviewee)

Overall, you demonstrated good problem-solving ability and were able to identify the right direction for the problem. You also showed good self-awareness during the interview by going back through your code and identifying areas where it could be improved, which is a valuable habit.
Communication & Explanation:
One area to improve is how you explain your code. Try not to explain the implementation line by line. Instead, focus on the core functionality and the reasoning behind the approach.
For example, rather than walking through every line, a stronger explanation would be:
"First, we'll sort the input. Then we'll iterate through the sorted characters and keep track of the current consecutive sequence and the maximum length we've seen."
Code Quality
Be careful with comments that simply repeat what the code already says. For example, a comment immediately next to a line explaining exactly what that line does can create unnecessary noise and may be considered a code smell.
Comments are most useful when they explain why something is being done, rather than simply describing what the code is doing.
Testing
You should also become more comfortable with testing your solutions directly in Python. Python makes it very easy to quickly test different inputs and edge cases.
I’d recommend learning a few basic Python testing techniques and getting into the habit of running examples such as:

Feedback about Colossal Narwhal (the interviewer)

Very helpful feedback from the interviewer. I feel he did a great job guiding/correcting if the conversation got stuck without giving away answers. Communicated very well and provided very thorough feedback at the end.