2343. Query Kth Smallest Trimmed Number

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2343

class Solution:
    def smallestTrimmedNumbers(
        self, nums: List[str], queries: List[List[int]]
    ) -> List[int]:
        res = []
        for k, trim in queries:
            t = sorted((v[-trim:], i) for i, v in enumerate(nums))
            res.append(t[k - 1][1])
        return res