Skip to content

Instantly share code, notes, and snippets.

@AashishNandakumar
Created August 29, 2024 15:56
Show Gist options
  • Save AashishNandakumar/e03c45801fd916f09947dc3cd47e11f1 to your computer and use it in GitHub Desktop.
Save AashishNandakumar/e03c45801fd916f09947dc3cd47e11f1 to your computer and use it in GitHub Desktop.
class Solution:
#User function Template for python3
#Complete this function
def findFloor(self,A,N,X):
#Your code here
nums = A
x = X
n = N
l = 0
r = n-1
mem = -1
while l <= r:
mid = (l+r) // 2
if nums[mid] <= x:
mem = mid
l = mid + 1
else:
r = mid - 1
return mem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment