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.
Hi! First we must realize that adding to all but the chosen one is the same as subtracting from only the chosen one.
Then the other idea is that we must find the optimal solution.
For example, 0 4 4 could be solved like this:
0 4 4 -->
0 4 2 -->
0 4 0 -->
0 2 0 -->
0 0 0 -->
But the optimal solution is this:
0 4 4 -->
0 4 -1 -->
0 -1 -1 -->
-1 -1 -1 -->
This is what I call the 'base'. and I add it to the delta, and it turns out you have to make at least 3 trials. Hope this helps.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Equal
You are viewing a single comment's thread. Return to all comments →
Hi! First we must realize that adding to all but the chosen one is the same as subtracting from only the chosen one.
Then the other idea is that we must find the optimal solution. For example, 0 4 4 could be solved like this: 0 4 4 --> 0 4 2 --> 0 4 0 --> 0 2 0 --> 0 0 0 -->
But the optimal solution is this: 0 4 4 --> 0 4 -1 --> 0 -1 -1 --> -1 -1 -1 -->
This is what I call the 'base'. and I add it to the delta, and it turns out you have to make at least 3 trials. Hope this helps.