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
- Smallest number divisible by first n numbers
- Find numbers with K odd divisors in a given range
- Find numbers with n-divisors in a given range
- Smallest n digit number divisible by given three numbers
- Arrange given numbers to form the smallest number
- Find a range of composite numbers of given length
- Numbers that are not divisible by any number in the range [2, 10]
- Find the highest occurring digit in prime numbers in a range
- Count of Numbers in Range where the number does not contain more than K non zero digits
- Find the smallest number whose digits multiply to a given number n
- Find smallest number K such that K % p = 0 and q % K = 0
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.