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.
first I'm only considering one stack and calculating the sum and count number.Then I'm adding one element from second stack at a time to the calculated sum and comparing it with required sum.If the calculated sum is greater we subract the last added element of first stack from sum.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Two Stacks
You are viewing a single comment's thread. Return to all comments →
first I'm only considering one stack and calculating the sum and count number.Then I'm adding one element from second stack at a time to the calculated sum and comparing it with required sum.If the calculated sum is greater we subract the last added element of first stack from sum.