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.
Consider two stacks s1 = [17,1,1,1,8] and s2 = [8,8,4,5,9] and max sum = 20.
Using greedy approach you will select from s2 because 8 < 17. You will end up removing 3 ints from s2. Contrary to that if you pick from s1, you end up picking 4 ints.
Game of Two Stacks
You are viewing a single comment's thread. Return to all comments →
Consider two stacks s1 = [17,1,1,1,8] and s2 = [8,8,4,5,9] and max sum = 20. Using greedy approach you will select from s2 because 8 < 17. You will end up removing 3 ints from s2. Contrary to that if you pick from s1, you end up picking 4 ints.