We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Giving chocolate to everyone except the chosen person is the same as taking chocolate away from the chosen person. We don't care about how much chocolate they end up with, only that each person's amount is equal.

For example:

Give 5:
1 3 5
6 8 5 <-
Take 5:
1 3 5
1 3 0 <-
The two results are the same relative to themselves, just shifted:
1 3 0
+ 5 5 5
---------
6 8 5

## Equal

You are viewing a single comment's thread. Return to all comments →

SPOILER! Hint if you're stuck:

Giving chocolate to everyone except the chosen person is the same as taking chocolate away from the chosen person. We don't care about how much chocolate they end up with, only that each person's amount is equal.

For example:

The problem becomes much simpler now.

Also remember to look for caching opportunities.

Great remark, when you re-state the problem like this, it becomes easy. Thanks!

Thank you very much. When explain like that, the problems seem easier than

I did the same thing but my last testcase is going wrong :/

How does it make this easier?

Yes this helps us to change our range update to a single element update !