Question bank › Two Pointers
Dsa Two Pointers Easy

Employee Work Hours Balance

You are given an array where each element represents the number of hours an employee worked each week over N weeks. Your task is to find the longest continuous subsequence of weeks where the employee has not exceeded a specified number of hours H.\n\nInput Format: - A single line containing two integers N and H, followed by N space-separated integers representing the hours worked.\n\nOutput Format: - A single integer representing the length of the longest subsequence that does not exceed H hours.\n\nExample: Input: 5 12\n3 4 3 2 1\nOutput: 5 (All weeks are under 12 hours)

Key concepts

two_pointersarrayprefix_sum

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