# Matrix

Glasses are arranged in the form of triangle (on top of each other) as shown below: 1 2 3 4 5 6 7 8 9 10 ……………….. …………………. Liquid is poured into 1st glass (Glass no. 1). When it is full, then extra liquid will flow into the glasses 2 and 3 in equal quantities. […]

Given a binary matrix with all rows and col sorted. Write code to count the number of zeros in that matrix. For example, if the matrix is [0, 0, 0, 0, 1] [0, 0, 0, 1, 1] [0, 1, 1, 1, 1] [0, 1, 1, 1, 1] [1, 1, 1, 1, 1] Then output should […]

Given a character matrix in which some of the cells have alphabets written on them while other cells are empty (empty cells contains character ‘-‘ in them). For example consider the below matrix: A – – – B – – – C All characters are unique. Set character on all empty cells in such a […]

Given a matrix of integers of order M*N and coordinates of a rectangular region in the matrix, write code to find the sum of all the elements in that rectangular region. For example, if the input matrix is And co-ordinated given are (3,4) and (6, 8), then they represent the below rectangular region whose Sum […]

You are given the Ancestor matrix of a Binary tree, write an Algorithm to construct the corresponding tree. For example, the below tree: Will have the following ancestor Matrix The order of rows in the above matrix is not defined. I have kept it in the ascending order because the data in our nodes is […]