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.
- Equal Stacks
- Discussions
Equal Stacks
Equal Stacks
Sort by
recency
|
92 Discussions
|
Please Login in order to post a comment
Java 8 - Based on all way subtracting a cylinder from the highest stack. This naturally protects from indexing exceptions and negative values since 0,0,0 is always true.
I use a map for elements index and sums and increment index on the list with the lowest sum each loop
time O(n) space O(1)
Here is the approch for Time complexity O(n) and space complexity O(1).
Here is - HackerRank Equal Stacks problem solution in Python, Java, C++, C and javascript