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.
The description of this is terrible. This is what it's trying to ask of you.
You’re given a row of cubes, each with a length. You can only pick cubes from either end — leftmost or rightmost — one at a time. Your goal is to stack them vertically, so that each cube you place is not longer than the one below it.
In other words:
- You’re building a pile from bottom to top.
- Each new cube must be equal to or smaller than the one you just placed.
- You can only pick from the ends of the row — no grabbing from the middle.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Piling Up!
You are viewing a single comment's thread. Return to all comments →
The description of this is terrible. This is what it's trying to ask of you.
You’re given a row of cubes, each with a length. You can only pick cubes from either end — leftmost or rightmost — one at a time. Your goal is to stack them vertically, so that each cube you place is not longer than the one below it. In other words: - You’re building a pile from bottom to top. - Each new cube must be equal to or smaller than the one you just placed. - You can only pick from the ends of the row — no grabbing from the middle.