Given two integers n and k, the task is to find the kth smallest element from the range [1, n] after deleting all the odd numbers from the range.
Input: n = 8, k = 3
After deleting all the odd numbers from the range [1, 8]
2, 4, 6 and 8 are the only numbers left and 6 is the 3rd smallest.
Input: n = 8, k = 4
Approach: Since all odd numbers are removed so now only even numbers are left i.e. 2, 4, 6, 8, …..
Now, the kth smallest element will always be 2 * k.
Below is the implementation of the above approach:
Time Complexity: O(1)
- Find the number of divisors of all numbers in the range [1, n]
- Program to find count of numbers having odd number of divisors in given range
- Count all the numbers in a range with smallest factor as K
- Find the smallest twins in given range
- Find the deleted value from the array when average of original elements is given
- Find XOR of numbers from the range [L, R]
- Smallest number divisible by first n numbers
- Find numbers with n-divisors in a given range
- Find numbers with K odd divisors in a given range
- Arrange given numbers to form the smallest number
- Smallest n digit number divisible by given three numbers
- Find a range of composite numbers of given length
- Numbers that are not divisible by any number in the range [2, 10]
- Find smallest possible Number from a given large Number with same count of digits
- Find the highest occurring digit in prime numbers in a range
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.