Close
Topic list
Floor in BST
MEDIUM
30 mins
Binary Search Trees
Topics (Covered in this problem)
Problem solved
Skill meter
Binary Search Trees
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Floor in BST

Medium
0/80
Avg time to solve 30 mins
Success Rate 70 %
Share

## Problem Statement

#### For example:

``````In the above example, For the given BST  and X = 7, the greatest value node of the BST  which is smaller than or equal to  7 is 6.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````2
10 5 15 2 6 -1 -1 -1 -1 -1 -1
7
2 1 3 -1 -1 -1 -1
2
``````
##### Sample Output 1:
``````6
2
``````
##### Explanation of Sample Input 1:
``````In the first test case, the BST looks like as below:
``````

``````The greatest value node of the BST which is smaller than or equal to  7 is 6.

In the second test case, the BST looks like as below:
``````

``````The greatest value node of the BST which is smaller than or equal to  2 is 2.
``````
##### Sample Input 2:
``````2
5 3 10 2 4 6 15 -1 -1 -1 -1 -1 -1 -1 -1
15
5 3 10 2 4 6 15 -1 -1 -1 -1 -1 -1 -1 -1
8
``````
##### Sample Output 2:
``````15
6
``````
Auto
Console