LeetCode 213: House Robber II, Splitting the Circle into Two Linear Problems

Problem Input and Output Input: an integer array nums, where nums[i] is the money in the i-th house. The houses form a circle. Adjacent houses cannot both be robbed, so houses 0 and n - 1 cannot both be robbed either. Output: the maximum amount of money that can be robbed without triggering the alarm. Constraints: 1 <= nums.length <= 100, 0 <= nums[i] <= 1000. Examples Input: nums = [2,3,2] Output: 3 Explanation: Houses 0 and 2 are adjacent around the circle, so they cannot both be robbed; rob the house containing 3. Input: nums = [1,2,3,1] Output: 4 Explanation: We can rob indices 0 and 2, or indices 1 and 3. Input: nums = [1,2,3] Output: 3 This tutorial uses Python only and starts with the smallest first-last conflict. ...

September 22, 2026 · 11 min · map[name:Jeanphilo]

LeetCode 503: Where Does the Right Side End in a Circular Array?

Problem Requirement You are given a circular integer array nums. Return an array answer. For every index i: answer[i] = the first value strictly greater than nums[i] when moving right If one full trip around the array finds no greater value, answer[i] = -1. “Circular” means that moving past the final position continues from index 0. An index cannot travel one full circle and use itself as its own answer. ...

July 20, 2026 · 9 min · map[name:Jeanphilo]