FastPrepMost Cash Around a Circular Street
Problems/Most Cash Around a Circular Street

Most Cash Around a Circular Street

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: In the same first round as the straight-row version, the candidate also got the variant where the houses stand in a circle, so the first and last houses are neighbors. Pseudo-code was enough, and the report only links the problem.

The report gives no limits or examples. Here there are 1 to 400 houses with 0 to 1000 each, and a single house can be taken on its own. The examples are our own.

The judged task matches the report at about 95%.

Houses stand around a circular street. money[i] is the cash in house i, and house i is next to houses i - 1 and i + 1. Because the street is a circle, the first house (index 0) and the last house (index money.length - 1) are also next to each other.

You may collect the cash from any set of houses, but never from two houses that are next to each other. Return the largest total you can collect.

If there is only one house, it has no neighbors, so you can take it.

Function

maxLootCircle(money: int[]) → int

Examples

Example 1

money = [7,2,3,8,1,6]return = 16

Taking indexes 0, 3 and 5 would give 7 + 8 + 6 = 21, but on a circle index 5 is next to index 0, so that plan is not allowed. The best legal plan takes indexes 1, 3 and 5: 2 + 8 + 6 = 16. Plans that keep index 0 reach at most 7 + 8 = 15.

Example 2

money = [9,2,2,9]return = 11

The two 9s sit at the ends of the list, and on a circle the ends are neighbors, so you cannot take both. The best is one 9 plus the 2 that is not next to it: 9 + 2 = 11.

Example 3

money = [6]return = 6

With one house there are no neighbors, so take it.

Constraints

  • 1 <= money.length <= 400
  • 0 <= money[i] <= 1000

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public int maxLootCircle(int[] money) {
    // Write your code here.
}
Checking account…