Skip to content

Practice Query Kth Smallest Trimmed Number

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2343
LeetCode Problem

Query Kth Smallest Trimmed Number

Problem Statement

For each query [k, trim], keep only the rightmost trim digits of each equal-length string in nums. Order these trimmed values numerically, breaking ties by smaller original index, and return the original index of the kth value, counting from 1. Leading zeros are allowed. Each query uses the original full strings independently. Return the indices in query order. Follow-up: consider radix sort and its complexity.

Source: Query Kth Smallest Trimmed Number on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = ["102","473","251","814"], queries = [[1,1],[2,3],[4,2],[1,2]]
Output
[2,2,1,0]

# Example 2

Input
nums = ["24","37","96","04"], queries = [[2,1],[2,2]]
Output
[3,0]

Constraints

1 <= nums.length <= 100
1 <= nums[i].length <= 100
nums[i] consists of only digits.
All nums[i].length are equal.
1 <= queries.length <= 100
queries[i].length == 2
1 <= ki <= nums.length
1 <= trimi <= nums[i].length

Related LeetCode Problems

Practice more problems similar to Query Kth Smallest Trimmed Number.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.