# Floor in a Sorted Array

Problem Link: <https://practice.geeksforgeeks.org/problems/floor-in-a-sorted-array-1587115620/1>

```python
class Solution:
    #User function Template for python3
    
    #Complete this function
    def findFloor(self, nums,n,target):
        #Your code here
        
        def modifiedbsearch(nums,target,i,j):
            
            mid=(i+j)//2
            while(i<=j):
                
                if(nums[mid]==target):
                    self.floor=mid
                    return
                
                if(nums[mid]<target):
                    self.floor=mid
                    return modifiedbsearch(nums,target,mid+1,j)
                else:
                    return modifiedbsearch(nums,target,i,mid-1)
            
            
        self.floor=-1
        modifiedbsearch(nums,target,0,n-1)
        return self.floor
        
        


#{ 
 # Driver Code Starts
#Initial Template for Python 3


import math


def main():
        T=int(input())
        while(T>0):
            
            NX=[int(x) for x in input().strip().split()]
            N=NX[0]
            X=NX[1]

            A=[int(x) for x in input().strip().split()]
            
            obj = Solution()
            print(obj.findFloor(A,N,X))
            
            T-=1


if __name__ == "__main__":
    main()
# } Driver Code Ends
```
