Accepted solution in Python


#1

class Solution:
# @param A : list of list of integers
# @return a list of list of integers
def diagonal(self, A):
row_len = len(A)
col_len = len(A[0])

    B = []
    start_row = 0
    start_col = 0
    while True:
        C = []

        j = 0
        curr_row = start_row
        for j in range(start_col, col_len):
            C.append(A[j][curr_row])
            if curr_row == 0:
                break
            curr_row -= 1
        if C:
            B.append(C)
    
        if start_row < row_len - 1:
            start_row += 1
        else:
            start_col += 1

        if start_col > (col_len - 1):
            break
        
    return(B)