Given a sorted array arr[] containing unique elements and an integer k, your task is to find the index (0-based) of the largest element in the array that is less than or equal to k. This element is referred to as the "floor" of k. If no such element exists, return -1.
Topics
Companies
Articles
Examples:
Expected Time Complexity: O(log n)
Expected Auxiliary Space: O(1)
Constraints:
1 <= arr.size() <= 10^6
1 <= arr[i] <= 10^6
0 <= k <= arr[n-1]
Companies:
AmazonMicrosoftWalmart
Topics:
Sorting Algorithms
Please log in to access the Submissions tab, where you can review your progress and explore code submissions from other participants.
Please log in to access the Solution tab and view detailed answers and explanations.
Please log in to access the Discussion tab and join conversations with other participants.
Access Restricted: Please Login to access the code editor and test cases.