lenskart OA

Given a binary tree. (Don’t assume it as BST).Write a method to print cousins of a given node.
Note :- Cosuins are node present at the same level but not having the same parent.
Example -
Cousin of 22 => 45,75 (7 is not cousin)
Cousin of 45 => 7, 22 (75 is not cousin)
Cosuin of 7 => 45, 75 (22 is not cousin)
function signature-
void printCousins(Node *root,Node *givenNode){
//Write implemenetation
}
}

		     30
		 /         \
	   /             \
   15	             60
   /  \               /   \
7      22          45  75
        /   \
	  17	27

Given a maze information in form of nXn matrix.Each cell is either blocked or open(-1 for block and 0 for open).You have to start from leftmost-topmost cell A(0,0) and reach to buttom-most and rightmost cell B(n-1,n-1).You are allowed to move from current cell to one cell in right side (i+1,j) or one cell downward(i,j+1).PRINT a path to reach B.

Note :- you cannot move from a blocked cell.
Example -
Input -(No of rows,No of columns,status of each cell(0-> fine,-1-blocked)

4*4

0 0 0 0
0 -1 0 0
-1 0 0 0
0 0 0 0

Output -> (0,0) (0,1) (0,2) (1,2) (2,2) (3,2) (3,3)

Write a program to find how much water can be stored/traped,where the width of each bar is 1 unit
Ex-
Input - 6 (number of bars)
3 0 0 2 0 4 ( height of bars)
Output - 10