Skip to main content

LeetCode

📄️ 1877. Minimize Maximum Pair Sum in Array

he pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs. For example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8. Given an array nums of even length n, pair up the elements of nums into n / 2 pairs such that:Each element of nums is in exactly one pair, and The maximum pair sum is minimized. Return the minimized maximum pair sum after optimally pairing up the elements.

📄️ 3461. Check If Digits Are Equal in String After Operations I

You are given a string s consisting of digits. Perform the following operation repeatedly until the string has exactly two digits:For each pair of consecutive digits in s, starting from the first digit, calculate a new digit as the sum of the two digits modulo 10. Replace s with the sequence of newly calculated digits, maintaining the order in which they are computed. Return true if the final two digits in s are the same; otherwise, return false.

📄️ 3903. Smallest Stable Index I

You are given an integer array nums of length n and an integer k. For each index i, define its instability score as max(nums[0..i]) - min(nums[i..n - 1]).In other words max(nums[0..i]) is the largest value among the elements from index 0 to index i.min(nums[i..n - 1]) is the smallest value among the elements from index i to index n - 1.An index i is called stable if its instability score is less than or equal to k.Return the smallest stable index. If no such index exists, return -1.

📄️ 3904. Smallest Stable Index II

You are given an integer array nums of length n and an integer k.For each index i, define its instability score as max(nums[0..i]) - min(nums[i..n - 1]).In other words:max(nums[0..i]) is the largest value among the elements from index 0 to index i.min(nums[i..n - 1]) is the smallest value among the elements from index i to index n - 1.An index i is called stable if its instability score is less than or equal to k.Return the smallest stable index. If no such index exists, return -1.