Entries from 2019-04-02 to 1 day

Dominator 100% Solution in python

Question app.codility.com My Solution app.codility.com def solution(A): stack = [0]*len(A) size = 0 index = -1 count = 0 for i in range(len(A)): if size == 0: stack[size] = A[i] size += 1 else: if stack[size-1] != A[i]: size -= 1 else: sta…

StoneWall 100% Solution in python

Question app.codility.com My Solution app.codility.com 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: bloc…

Nesting 100% Solution in python

Question app.codility.com My Solution app.codility.com def solution(S): stack = [0]*len(S) size = 0 for i in range(len(S)): if S[i] is "(": stack[size] = S[i] size += 1 else: if size is 0: return 0 else: size -= 1 if size is 0: return 1 re…

Brackets 100% Solution in python

Question app.codility.com My Solution app.codility.com def solution(S): stack = [0]*len(S) size = 0 for i in range(len(S)): if S[i] is "(" or S[i] is "{" or S[i] is "[": stack[size] = S[i] size += 1 else: if size is 0: return 0 elif S[i] i…

Fish 100% Solution in Python

Notice Recently I got some codility challenges from companies and they don't allow me to use javascript. As a results, I learn the basic coding style in python from the very beginning on YouTube Python Programming Tutorial - 1 - Installing…