Question:codility Lesson7 StoneWall
My Answer:
def solution(H):
blockcnt = 0
stack = []
for height in H:
while len(stack) != 0 and stack[-1] > height:
stack.pop()
blockcnt += 1
if len(stack) == 0 or height > stack[-1]:
stack.append(height)
#blockcnt += 1
blockcnt += len(stack)
return blockcnt