Count numbers up to N having Kth bit set
Given two integers N and K, the task is to find the count of numbers up to N having K-th (0-based indexing) bit set. Examples: Input: N = 14, K = 2Output: 7Explanation: The numbers less than equal to 14, having 2nd bit set are 4, 5, 6, 7, 12, 13, and 14. Input: N = 6, K = 1Output: 3Explanation: The