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
|
972 Discussions
|
Please Login in order to post a comment
Here is HackerRank Piling Up! in python solution - https://programmingoneonone.com/hackerrank-piling-up-problem-solution-in-python.html
from collections import deque
def is_stackable(cubes): dq = deque(cubes) last = float('inf')
t_cases = int(input())
for _ in range(t_cases): n = int(input()) cubes = list(map(int, input().split())) print(is_stackable(cubes))
My Soln:
from math import ceil T = int(input()) my_list = [] for _ in range(T*2): my_list.append(list(map(int, input().split())))
new_list = []
for i in range(1,len(my_list),2): new_list.append(my_list[i])
for j in range(0,len(new_list)): for k in range(0,ceil(len(new_list[j])/3)): if ( (new_list[j][k + 1] <= new_list[j][len(new_list[j]) - (k + 1)] and new_list[j][len(new_list[j]) - (k + 2)] <= new_list[j][len(new_list[j]) - (k + 1)]) or (new_list[j][k + 1] <= new_list[j][k] and new_list[j][len(new_list[j]) - (k + 2)] <= new_list[j][k])): passed_all = True