StoneWall 100% Solution in python
Question
My Solution
def solution(H): block = 0 stack = [0]*len(H) size = 0 for i in range(len(H)): while size > 0 and stack[size-1] > H[i]: size -= 1 if size > 0 and stack[size-1] == H[i]: pass else: block += 1 stack[size] = H[i] size += 1 return block
Note
I read this official tutorial at first and followed this:
https://codility.com/media/train/solution-stone-wall.pdfcodility.com