Question bank › Sliding Window
Dsa Sliding Window Easy

Count Subarrays with Sum at Most K

Given an array of integers and an integer k, count the number of contiguous subarrays whose sum is at most k. Input format: - The first line contains an integer n (length of the array). - The second line contains n space-separated integers (the array). - The third line contains an integer k. Output format: - Print the count of subarrays with sum at most k. Example: Input: 5 1 2 3 4 5 7 Output: 10

Key concepts

sliding_windowarraysum

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.