Tap here to switch tabs
Problem
Submissions

Problem: House Robber V

Try to solve the House Robber V problem.

Statement

You are given two 00 indexed integer arrays nums and colors, both of length n.

The value nums[i] represents the amount of money at the iextthi^{ ext{th}} house, and colors[i] represents the color of the iextthi^{ ext{th}} house.

You want to rob houses to maximize the total amount of money robbed. You cannot rob two adjacent houses if they have the same color.

Return the maximum amount of money you can rob.

Constraints:

  • 1≤1 \leq n ==== nums.length ==== colors.length ≤105\leq 10^5

  • 1≤1 \leq nums[i], colors[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: House Robber V

Try to solve the House Robber V problem.

Statement

You are given two 00 indexed integer arrays nums and colors, both of length n.

The value nums[i] represents the amount of money at the iextthi^{ ext{th}} house, and colors[i] represents the color of the iextthi^{ ext{th}} house.

You want to rob houses to maximize the total amount of money robbed. You cannot rob two adjacent houses if they have the same color.

Return the maximum amount of money you can rob.

Constraints:

  • 1≤1 \leq n ==== nums.length ==== colors.length ≤105\leq 10^5

  • 1≤1 \leq nums[i], colors[i] ≤105\leq 10^5