FastPrepHouse Robber II
Problems/House Robber II

House Robber II

Apple logoApple● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Apple full-time online assessment. The statement with houses in a circle and its examples are about 98% the same as the report. The report's note about a tree DP approach does not fit that statement, so we follow the circle layout it states.

Given an integer array nums, where nums[i] is the money in house i, return the most money you can rob. The houses stand in a circle, so the first and last houses are neighbors. You cannot rob two neighboring houses, or an alarm goes off.

You may skip every house. If there is only one house, you may rob it.

Function

robCircular(nums: int[]) → int

Examples

Example 1

nums = [2,3,2]return = 3

The first and last houses each hold two, but they are neighbors around the circle. Robbing only the middle house gives three, the best total.

Example 2

nums = [1,2,3,1]return = 4

Rob the first house (one) and the third house (three). They are not neighbors, so the total is four.

Example 3

nums = [0]return = 0

The only house holds no money, so the answer is zero.

Constraints

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

More Apple interview questions

  • Merge IntervalsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merge Two Strings by Maximum Boundary OverlapOA · Seen Sep 2026
  • Collect Letters Along a Unique Grid PathOA · Seen Aug 2025
  • Maximum Weight in Two BagsOA · Seen Aug 2025
  • Ignore SectionsOA · Seen Mar 2024
  • Gas Station Circular TourOA · Seen Nov 2021
  • Clone an Undirected Graph StateOA · Seen Mar 2021
  • Longest Increasing Subsequence LengthOA · Seen Feb 2021
  • Maximum Later DifferenceOA · Seen Feb 2021
  • Topological OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Card Game: Best First-Player ScoreShopify · OAShopify interview questions
  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Subarray SumStraive · OA
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
  • Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
  • API Bandwidth AllocationArista Networks · OAArista Networks interview questions

Interview reports that mention this question

  • Apple India SWE New Grad Interviews: 5 Experiences

Apple interview experiences

  • Apple SWE Phone Screen: Subarray Products: 1 Experience
  • Apple New Grad SWE Java, Coding and Manager Rounds: 1 Experience
  • Apple AI Coding and Related Interviews: 17 Experiences
  • Apple New Grad SWE Phone Screens: 12 Experiences (Part 3 of 3)
  • Apple New Grad SWE and Embedded: 16 Experiences (Part 2 of 3)
All Apple interview questionsSee Apple hiring insights
Saved
class Solution {
    public int robCircular(int[] nums) {
        // Write your solution here.
    }

}
Checking account…