Dsa
Arrays
Warm-up
Find Adjacent Duplicates
Write a function that reads a list of strings from input, and returns a new list containing only the strings that have adjacent duplicates. Each input string is separated by a newline. The output should be a list of strings with duplicates side by side in the original order. Example input: 'apple\napple\nbanana\ncherry\ncherry\npeach' --> Output: ['apple', 'cherry']
Key concepts
arraysstringsiteration
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now