The core logic is simple enough, just track the previous element and skip if it matches the current one.
Clarify the exact semantics of 'consecutive duplicate lines' (e.g., whether to compare exact strings or trimmed lines, and whether to preserve the first or last occurrence). Then implement a simple linear scan that compares each line to the previous one, optionally using a generator for memory efficiency. Discuss trade-offs like in-place vs. new list, and edge cases such as empty input or single line.
Pro tip: Mention that this is essentially a streaming deduplication problem, so a generator-based solution is more memory-efficient for large inputs and aligns with Unix philosophy. Also, proactively ask whether the function should modify the input in-place or return a new sequence, as this affects design and testing.
Ask about input type (list, iterator, file), whether to compare exact strings or normalized (e.g., trimmed), and whether to preserve first or last occurrence. Identify edge cases: empty input, all duplicates, no duplicates, single element.
Decide between a simple loop with a result list, an in-place algorithm, or a generator. Consider time O(n) and space O(1) extra if using in-place or generator, vs O(n) for a new list.
Write a function that iterates through the sequence, keeping track of the previous line, and yields or appends the current line only if it differs from the previous. Handle the first element separately or initialize previous to a sentinel.
Walk through examples: ['a','a','b','b','a'] -> ['a','b','a']; empty list; single element; all same. Verify that non-consecutive duplicates are preserved.
Mention trade-offs: in-place saves memory but mutates input; generator is lazy but can only be iterated once. Extend to case-insensitive comparison or ignoring whitespace if needed.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.