 Ceil The Floor
##### Submissions: 1876   Accuracy: 22.12%   Difficulty: Basic   Marks: 1

Given an unsorted array arr[] and an element x, find floor and ceiling of x in arr[0..n-1].

Floor of x is the largest element which is smaller than or equal to x. Floor of x doesn’t exist if x is smaller than smallest element of arr[].

Ceil of x is the smallest element which is greater than or equal to x. Ceil of x doesn’t exist if x is greater than greates element of arr[].

```Examples:

Input : arr[] = {5, 6, 8, 9, 6, 5, 5, 6}
x = 7
Output : Floor = 6
Ceiling = 8

Input : arr[] = {5, 6, 8, 9, 6, 5, 5, 6}
x = 10
Output : Floor = 9
Ceil doesn't exist.

Input : arr[] = {5, 6, 8, 9, 6, 5, 5, 6}
x = 2
Output : Floor doesn't exist
Ceil = 5```

Example :
Input :

The first line of input contains an integer T denoting the Test cases. Then T test cases follow.
First line contains no. of array elements - N and value of x
Second line contains array elements A[i]

Output :
Floor and Ceil Value of x

Constraints :
1 ≤ T ≤ 100
1 ≤ N, x ≤ 10^5
0 ≤ A[i] ≤ 10^6

Input :
2
8 2
5 6 9 8 6 5 5 6
11 264
147 154 383 223 345 30 376 111 33 186 72

Output :
Floor doesn't exist
5
223
345

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Mohit Gupta_OMG :)
Author: Mohit Gupta 4

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.