IDFC First Bank - Chennai
Summary
I was asked to solve a House Robber variant with limited adjacency during an interview at IDFC First Bank in Chennai.
Full Experience
House Robber with Limited Adjacency (Circular)
Problem Statement
You are given an integer array nums where each element represents the amount of money in a house. The houses are arranged in a circle, meaning the first and last houses are adjacent.
You want to maximize the total amount of money you can rob under the following constraints:
Constraints
- You cannot rob more than two consecutive houses (i.e., picking 3 consecutive houses is not allowed).
- You can rob adjacent houses at most once. Across the entire selection, there can be at most one pair of adjacent houses.
- Since the houses are in a circle, house 0 and house n‑1 are also considered adjacent.
Goal
Return the maximum amount of money you can rob without violating the above constraints.
Interview Questions (1)
House Robber with Limited Adjacency (Circular)
You are given an integer array nums where each element represents the amount of money in a house. The houses are arranged in a circle, meaning the first and last houses are adjacent.
Constraints:
- You cannot rob more than two consecutive houses (picking three consecutive houses is not allowed).
- You can rob adjacent houses at most once; there can be at most one pair of adjacent houses in the selection.
- House 0 and house n‑1 are considered adjacent due to the circular arrangement.
Return the maximum amount of money you can rob without violating these constraints.