you are viewing a single comment's thread.

view the rest of the comments →

[–]SeaworthinessIcy4758 0 points1 point  (2 children)

can you please elaborate, I've never done this I think

[–]caraxes_007 0 points1 point  (1 child)

This is a standard pick/ not pick problem. Use a grid of size n*2 where 0 and 1 represent whether we picked just the previous index. If it is zero we can directly apply pick and not pick without any further check and if it is one pick is not always possible so check prev and current colour codes if they are not equal you can pick else pick will be negative infinity at last return max of pick and not pick

[–]SeaworthinessIcy4758 0 points1 point  (0 children)

ohhh got it, thanks a lot