Tap here to switch tabs
Problem
Submissions

Problem: House Robber V

House Robber V asks you to choose houses for the highest total value, while never robbing adjacent houses that share the same color.

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 ithi^{ {th}} house, and colors[i] represents the color of the ithi^{ {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

House Robber V asks you to choose houses for the highest total value, while never robbing adjacent houses that share the same color.

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 ithi^{ {th}} house, and colors[i] represents the color of the ithi^{ {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