Maximize sum of non-adjacent values
Company: Samsung
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates algorithmic problem-solving skills, specifically understanding of dynamic programming and optimization when selecting non-adjacent elements, within the Coding & Algorithms domain.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([1,2,3,1],)
Expected Output: 4
Explanation: Prompt example 1.
Input: ([2,7,9,3,1],)
Expected Output: 12
Explanation: Prompt example 2.
Input: ([],)
Expected Output: 0
Explanation: No houses.
Hints
- Choose a representation that makes the requested operation direct.
- Handle empty inputs and boundary cases first.