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.
As the question asked we should calculate the sum of 4 elements so it means we can subtract an item of the total amount.
I calculated total sum at first loop then I initialized max with ( sum- last element) and min with ( sum- last item) so the second loop is not involved last one.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →
As the question asked we should calculate the sum of 4 elements so it means we can subtract an item of the total amount. I calculated total sum at first loop then I initialized max with ( sum- last element) and min with ( sum- last item) so the second loop is not involved last one.