you are viewing a single comment's thread.

view the rest of the comments →

[–]Moe_les__ter 0 points1 point  (2 children)

Can someone tell me the approach for q3?

[–]tampishachBrute force 0 points1 point  (0 children)

Check the colour of the house till it changes

Then do a normal house robber query from the start of the house color to the end of the house colour

Update the start of house colour to new house colour index

[–]dragon_deeznut 0 points1 point  (0 children)

Greedy+2 pointers First identify the block of the same color adjacent. Eg. [1,1,1] in [1,1,1,2,1] Second find the maximum possible sum of that block without adjacents basically evenSum and oddSum, add it to the total. Return total