PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Samsung

Maximize sum of non-adjacent values

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic problem-solving skills, specifically understanding of dynamic programming and optimization when selecting non-adjacent elements, within the Coding & Algorithms domain.

  • medium
  • Samsung
  • Coding & Algorithms
  • Machine Learning Engineer

Maximize sum of non-adjacent values

Company: Samsung

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem You are given an integer array `nums` representing the amount of money available at each house along a street. If you take money from house `i`, you **cannot** take money from house `i-1` or `i+1` (no two selected houses may be adjacent). Return the **maximum** amount of money you can take. ## Input - `nums`: an array of integers (typically non-negative) ## Output - An integer: the maximum sum achievable without choosing adjacent elements. ## Constraints - `1 <= nums.length <= 10^5` - `0 <= nums[i] <= 10^9` ## Examples - Input: `nums = [1, 2, 3, 1]` → Output: `4` (choose 1 and 3) - Input: `nums = [2, 7, 9, 3, 1]` → Output: `12` (choose 2, 9, 1)

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.

Related Interview Questions

  • Count islands in a binary grid - Samsung (easy)
  • Validate palindrome with constraints - Samsung (Medium)
Samsung logo
Samsung
Mar 1, 2026, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
1
0

Problem

You are given an integer array nums representing the amount of money available at each house along a street.

If you take money from house i, you cannot take money from house i-1 or i+1 (no two selected houses may be adjacent).

Return the maximum amount of money you can take.

Input

  • nums : an array of integers (typically non-negative)

Output

  • An integer: the maximum sum achievable without choosing adjacent elements.

Constraints

  • 1 <= nums.length <= 10^5
  • 0 <= nums[i] <= 10^9

Examples

  • Input: nums = [1, 2, 3, 1] → Output: 4 (choose 1 and 3)
  • Input: nums = [2, 7, 9, 3, 1] → Output: 12 (choose 2, 9, 1)

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Samsung•More Machine Learning Engineer•Samsung Machine Learning Engineer•Samsung Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.