All Posts

Leetcode 2900: Longest Unequal Adjacent Groups Subsequence I

You are given two arrays: words (a list of distinct strings) and groups (a binary array where each element corresponds to an entry in words). Your task is to select the longest alternating subsequence of words, where each consecutive word has a different corresponding group value. For each pair of consecutive words in the subsequence, the corresponding values in groups must be different.

Leetcode 2901: Longest Unequal Adjacent Groups Subsequence II

You are given an array of strings 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.

Leetcode 2904: Shortest and Lexicographically Smallest Beautiful String

You are given a binary 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.

Leetcode 2914: Minimum Number of Changes to Make Binary String Beautiful

You are given a 0-indexed binary string s of even length. A string is considered beautiful if it can be divided into substrings where each substring has an even length and contains only ‘0’s or only ‘1’s. You can modify any character in s to ‘0’ or ‘1’. The task is to return the minimum number of changes required to make the string beautiful.

Leetcode 2933: High-Access Employees

You are given a 2D array, access_times, where each entry contains an employee’s name and their system access time in 24-hour format (HHMM). An employee is considered ‘high-access’ if they accessed the system at least three times within any one-hour window. The task is to identify all such high-access employees and return their names.

Leetcode 2937: Make Three Strings Equal

You are given three strings: s1, s2, and s3. In each operation, you can choose one of these strings and remove its rightmost character. The goal is to determine the minimum number of operations required to make all three strings identical. If it’s impossible to make them equal, return -1.