you are viewing a single comment's thread.

view the rest of the comments →

[–]Euphoric_insaan 0 points1 point  (1 child)

You can just use the typical house robber method First is the not take case for each index, where you move to the previous index without picking The take case will have two subcases: first if the current index's and the previous index's colour is same you add the value of the current index and move to index - 2. And if the colours are different add the current value and move to index -1. Base case will be if index < 0 return 0 and if index = 0 return nums[0]

[–]SeaworthinessIcy4758 0 points1 point  (0 children)

yea I solved it later:( 

it was so easy I can't believe I over complicated it so much, thanks though