Question bank › Dynamic Programming
Dsa Dynamic Programming Hard

Maximum Sum of Non-Adjacent Elements

Given an array of integers, you are to find the maximum sum of non-adjacent elements, meaning that if you pick an element at index i, you cannot pick the elements at indices i-1 and i+1. Write a function that returns this maximum sum. Input: - The first line contains an integer n, the number of elements in the array. - The second line contains n space-separated integers representing the elements of the array. Output: - A single integer representing the maximum sum of non-adjacent elements. Example: Input: 6 3 2 5 10 7 Output: 15

Key concepts

dynamic_programmingarrays

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.