Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def findKthNumber(self, m: int, n: int, k: int) -> int:
- l = 0
- r = m * n
- def check(x):
- i = n
- j = 1
- count = 0
- while i > 0 and j <= m:
- if i * j <= x:
- count += i
- j += 1
- else:
- i -= 1
- return count
- while r - l > 1:
- mid = l + (r - l) // 2
- if check(mid) < k:
- l = mid
- else:
- r = mid
- return r
Add Comment
Please, Sign In to add comment