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.
- Prepare
- Python
- Collections
- Piling Up!
- Discussions
Piling Up!
Piling Up!
Sort by
recency
|
981 Discussions
|
Please Login in order to post a comment
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.
Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import deque
num_of_tests = int(input())
for ntest in range(num_of_tests): # read number of blocks num_of_blocks = int(input())
here is my solution and works