Description
Q.1 Maximum height of the staircase
Given an integer A representing the square blocks. The height of each square block is 1. The task is to create
a staircase of max height using these blocks. The first stair would require only one block, the second stair
would require two blocks and so on. Find and return the maximum height of the staircase.
Sample Input
arr[] = {10, 8, 9, 2, 0}
Sample Output:
4
Explanation:
The max height of the stairs with 10 blocks is 4.
Sample Input:
arr[] = {16, 11, 10, 8, 4}
Sample Output:
5
Explanation:
The max height of the stairs with 16 blocks is 5.
Q.2 Square Root of Integer
Given an Integar A. Compute and return the square root of A. If A is not a perfect square, return floor(sqrt(A)).
[Instruction: DO NOT USE SQRT FUNCTION FROM STANDARD LIBRARY]
Sample Input: Enter number 24
Sample output: 4
Sample Input: Enter number 101
Sample output: 10
Q.3 Search in a row wise and column wise sorted matrix.
Given an n x n matrix and a number x, find the position of x in the matrix if it is present in it. Otherwise, print
“Not Found”. In the given matrix, every row and column is sorted in increasing order. The designed algorithm
should have linear time complexity.
Input:
mat[4][4] = { {10, 20, 30, 40},
{15, 25, 35, 45},
{27, 29, 37, 48},
{32, 33, 39, 50}};
x = 29
Output: Found at (2, 1)
Input : mat[4][4] = { {10, 20, 30, 40},
{15, 25, 35, 45},
{27, 29, 37, 48},
{32, 33, 39, 50}};
x = 100
Output : Element not found