Question bank › Sliding Window
Dsa Sliding Window Medium

Maximum Sum of Consecutive Prime Numbers

Given a list of integers, find the maximum sum of any contiguous subarray that contains only prime numbers. Each prime number should be counted in the sum, and non-prime numbers will terminate the current summation. The input consists of one line: the number of integers n, followed by n integers. Output a single integer representing the maximum sum of prime-only subarrays. Example: Input: 7 3 5 8 7 2 9 11 Output: 18

Key concepts

sliding_windowprime_numberssums

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.