10 Find Floor of an element in a Sorted Array

Опубликовано: 07 Октябрь 2024
на канале: Aditya Verma
102,246
2.5k

FIND FLOOR OF AN ELEMENT IN A SORTED ARRAY:

Given a sorted array and a value x, the floor of x is the largest element in array smaller than or equal to x. Write efficient functions to find floor of x.

Example:

Input : arr[] = {1, 2, 8, 10, 10, 12, 19}, x = 5
Output : 2
2 is the largest element in arr[] smaller than 5.

PROBLEM STATEMENT LINK:https:https://www.geeksforgeeks.org/floor-i...
PLAYLIST LINK:   • Binary Search | Interview Questions |...   .
------------------------------------------------------------------------------------------
Here are some of the gears that I use almost everyday:

🖊️ : My Pen (Used in videos too): https://amzn.to/38fKSM1
👨🏻‍💻 : My Apple Macbook pro: https://amzn.to/3w8iZh6
💻 : My gaming laptop: https://amzn.to/3yjcn23
📱 : My Ipad: https://amzn.to/39yEMGS
✏️ : My Apple Pencil: https://amzn.to/3kMnKYf
🎧 : My Headphones: https://amzn.to/3kMOzM7
💺 : My Chair: https://amzn.to/385weqR
🛋 : My Table: https://amzn.to/3kMohtd
⏰ : My Clock: https://amzn.to/3slFUV3
🙋🏻‍♀️ : My girlfriend: https://amzn.to/3M6zLDK ¯\_(ツ)_/¯

PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.