[LeetCode] Maximum Number That Sum of the Prices Is Less Than or Equal to K

1 · · Jan. 14, 2024, 4:58 a.m.
3007. Maximum Number That Sum of the Prices Is Less Than or Equal to K You are given an integer k and an integer x. Consider s is the 1-indexed binary representation of an integer num. The price of a number num is the number of i‘s such that i % x == 0 and s[i] is a set bit. Return the greatest integer num such that the sum of prices of all numbers from 1 to num is less than or equal to k. Note: In the binary representation of a number set bit is a bit of value 1. The binary representation of ...