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 problem statement seems a bit odd to me.
Here's a better explanation of the problem statement for future porblems solvers.
Piling Up! Problem
What Are We Trying to Do?
Your task is to decide if it is possible to build a single tower of blocks from a given row of blocks. The tower (stack) must follow these rules:
Blocks in the stack must be in non-increasing order (each block on top must be smaller than or equal to the one below it).
You must use all the blocks in the row to complete the stack.
What Is the Situation?
You are given a row of blocks, each with a size written on it (a number).
At each step, you are allowed to pick a block from either the left end or the right end of the row. Once a block is picked, it is added to your stack (tower) and removed from the row.
You can smartly (freely) choose which end to pick from at every step.
Rules You Must Follow:
You can only pick blocks from the two ends (leftmost or rightmost block) of the row.
Blocks must be added to the stack in non-increasing order:
A block can only be added if its size is less than or equal to the block already on top of the stack.
You must use all the blocks in the row to complete the stack.
What You Have to Decide:
For each test case:
If you can create a valid stack by following the rules, print "Yes".
If it is impossible to create a valid stack, print "No".
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 problem statement seems a bit odd to me.
Here's a better explanation of the problem statement for future porblems solvers.
Piling Up! Problem
What Are We Trying to Do?
Your task is to decide if it is possible to build a single tower of blocks from a given row of blocks. The tower (stack) must follow these rules:
What Is the Situation?
Rules You Must Follow:
What You Have to Decide:
For each test case: