FastPrepHouse Robber II
Problems/House Robber II

House Robber II

Kotak Mahindra Bank logoKotak Mahindra Bank● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names House Robber II without restating its full contract. This practice version uses the conventional circular-house task with explicit bounds and edge cases.

Houses stand in a circle. The nonnegative integer nums[i] is the value available in house i. Select houses with no two adjacent and return the maximum total value.

The first and last houses are adjacent. For this exercise, assume there is at least one house, selecting none is allowed, and a single house may be selected.

Function

robCircular(nums: int[]) → int

Examples

Example 1

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

The two houses worth 2 are adjacent around the circle, so choose the middle house worth 3.

Example 2

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

Choose values 1 and 3 at indices 0 and 2; they are not adjacent.

Example 3

nums = [5]return = 5

The only house may be selected.

Constraints

  • 1 <= nums.length <= 10^5.
  • 0 <= nums[i] <= 10^4.
  • The result fits in a signed 32-bit integer.

More Kotak Mahindra Bank problems

  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell Stock IIONSITE INTERVIEW · Seen Nov 2026
  • Maximum Non-Adjacent Coins in Two RowsONSITE INTERVIEW · Seen Oct 2026
All Kotak Mahindra Bank interview questionsSee Kotak Mahindra Bank hiring insights
Saved
class Solution {
    public int robCircular(int[] nums) {
        // Write your code here.
    }
}
Checking account…