Download Kth Smallest Number in Multiplication Table.py
class Solution: def findKthNumber(self, m: int, n: int, k: int) -> int: # https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/solution/ def enough(x): count = 0 # ith row [i, 2*i, 3*i, ..., n*i] # for each column, k = x // i for i in range(1, m+1): count += min(x // i, n) return count >= k lo, hi = 1, m * n while lo < hi: mi = (lo + hi) // 2 if not enough(mi): lo = mi + 1 else: hi = mi return lo
Leetcode 668 Kth Smallest Number in Multiplication Table problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.
Feedback is the most important part of any website.
If you have any query, suggestion or feedback, Please feel free to contact us.