Given a sorted array nums and a value x, find the floor of x in the array. The floor is the greatest element in the array that is less than or equal to x. If no such element exists, return -1.
{
"nums": [
1,
2,
8,
10,
10,
12,
19
],
"x": 5
}2{
"nums": [
1,
2,
8,
10,
10,
12,
19
],
"x": 20
}19{
"nums": [
1,
2,
8,
10,
10,
12,
19
],
"x": 0
}-1Sign in to Run Code and Submit