All Posts
Leetcode 2901: Longest Unequal Adjacent Groups Subsequence II
words
and an array groups
of equal length n
. The task is to find the longest subsequence from words
such that the corresponding elements in groups
are unequal for adjacent elements in the subsequence, and the Hamming distance between consecutive strings in the subsequence is exactly 1. A string’s Hamming distance with another string is the number of positions at which their characters differ. The subsequence should be returned as an array of strings in the order of the subsequence indices.
You are given an array of strings Leetcode 2904: Shortest and Lexicographically Smallest Beautiful String
s
and a positive integer k
. A substring of s
is considered ‘beautiful’ if it contains exactly k
occurrences of ‘1’. Your task is to return the lexicographically smallest substring of the shortest length that has exactly k
‘1’s. If no such substring exists, return an empty string.
You are given a binary string Leetcode 2905: Find Indices With Index and Value Difference II
You are given an integer array nums of size n, an integer indexDifference, and an integer valueDifference. Your task is to find two indices i and j that satisfy the following conditions:
- abs(i - j) >= indexDifference,
- abs(nums[i] - nums[j]) >= valueDifference.
Return the indices [i, j] if such a pair exists, or [-1, -1] if no such pair exists. If there are multiple pairs, any valid pair is acceptable.