• Java - Tutorials

    HackerRank Solution – Problem Solving – Game of Two Stacks

    Alexa has two stacks of non-negative integers, stack a[n] and stack b[m] where index 0 denotes the top of the stack. Alexa challenges Nick to play the following game: In each move, Nick can remove one integer from the top of either stack a or stack b. Nick keeps a running sum of the integers he removes from the two stacks. Nick is disqualified from the game if, at any point, his running sum becomes greater than some integer maxSum given at the beginning of the game. Nick’s final score is the total number of integers he has removed from the two stacks. This article shows the solution of the interview preparation problem…