Dsa
Sliding Window
Medium
Max Sum of Non-Adjacent Elements
You are given an array of integers. You need to find the maximum sum of non-adjacent elements. You can choose any element from the array but cannot pick two consecutive elements.
Input Format:
- A single line of integers (space-separated).
Output Format:
- A single integer representing the maximum sum of non-adjacent elements.
Example:
Input:
3 2 5 10 7
Output:
15
Key concepts
sliding_windowdynamic_programmingarray
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