Question bank › Linked List
Dsa Linked List Easy

Lookahead De-duplication

Given a linked list and an integer K, remove any node if its value appears at least once in the next K nodes of the list. If there are fewer than K nodes remaining, check all remaining nodes. Input: 1. A line of space-separated integers representing the list. 2. An integer K. Output: The filtered list values space-separated. Example: Input: 1 2 1 3 2 4 2 Output: 2 1 3 2 4 (First '1' was removed because '1' appeared in the next 2 nodes [2, 1])

Key concepts

linked_listsearchfiltering

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.