Question bank › Sliding Window
Dsa Sliding Window Easy

The Tech Stack

A developer is looking at a sequence of coding tasks. Each task has a 'technology tag' (an integer) and a 'point value'. The developer wants to pick the longest continuous sequence of tasks such that they work with at most K distinct technologies, but the total point value of the tasks in the window must be at least P. If no such window exists, output 0. Example: Input: 5 2 10 1 2 1 2 3 5 5 5 5 20 Output: 4 Explanation: K=2, P=10. Tags are [1, 2, 1, 2, 3] and points are [5, 5, 5, 5, 20]. The sequence of tags [1, 2, 1, 2] has 2 distinct technologies and 20 points. Length is 4.

Key concepts

sliding_windowhash_map

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.