House Robber
Updated
Problem statement
You are given an array nums, where nums[i] is the amount of money in house i.
Adjacent houses cannot both be robbed. Return the maximum total amount that can be robbed without choosing two adjacent houses.
Function
rob(nums: int[]) → intExamples
Example 1
nums = [1,2,3,1]return = 4Rob houses 0 and 2 for 1 + 3 = 4.
Example 2
nums = [2,7,9,3,1]return = 12Rob houses 0, 2, and 4 for 2 + 9 + 1 = 12.
Example 3
nums = [5]return = 5The only house can be robbed.
Constraints
1 <= nums.length <= 100.0 <= nums[i] <= 400.
More Bloomberg LP Phone Screen questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Maximum Sum with K-Element SkippingPhonePe · ONSITE INTERVIEWPhonePe interview questions
- Assign Escalations to TeamsAmazon · ONSITE INTERVIEW
- Maximum Subarray Sum with One DeletionServiceNow · PHONE SCREENServiceNow interview questions
- Distinct Subset SumsGoogle · ONSITE INTERVIEWGoogle interview questions
- Maximum Product of a Contiguous SubarrayLinkedIn · PHONE SCREENLinkedIn interview questions
- Count Subsets With a Target SumSafe Security · ONSITE INTERVIEW
- Longest Increasing SubsequenceByteDance · PHONE SCREENByteDance interview questions
- Jump GamePaytm · PHONE SCREENPaytm interview questions
- Maximum Subarray Sum with One DeletionOracle · ONSITE INTERVIEWOracle interview questions
- Query Words Within K PositionsPalantir · PHONE SCREENPalantir interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)