All Posts

Leetcode 1763: Longest Nice Substring

A string is considered nice if every letter that appears in the string appears both in uppercase and lowercase. For example, ‘aA’ and ‘bB’ are nice strings, but ‘a’ and ‘B’ are not. Given a string s, find the longest nice substring of s. If there are multiple longest nice substrings, return the one that appears first. If no nice substring exists, return an empty string.

Leetcode 1985: Find the Kth Largest Integer in the Array

You are given an array of strings nums, where each string represents a non-negative integer. You need to find the kth largest integer in the array. Note that duplicates should be considered distinctly. For example, if the array is [‘1’, ‘2’, ‘2’], the first largest integer is ‘2’, the second largest is also ‘2’, and the third largest is ‘1’.

Leetcode 2343: Query Kth Smallest Trimmed Number

You are given a list nums where each string contains digits of the same length. Additionally, you are provided a list of queries, where each query is represented by two integers [ki, trimi]. For each query, trim each number in nums to its rightmost trimi digits, then find the index of the kith smallest trimmed number. If two numbers are identical after trimming, the one with the lower index is considered smaller. Reset the numbers in nums for the next query.