All Posts

Leetcode 2512: Reward Top K Students

You are given two lists of words: one representing positive feedback and the other representing negative feedback. Each feedback word affects a student’s points: a positive word adds 3 points, while a negative word subtracts 1 point. For each feedback report, which is associated with a student, calculate the total score by counting the occurrences of positive and negative words. After evaluating all reports, return the top k students based on their total points. In case of a tie in points, the student with the lower ID should rank higher.

Leetcode 2515: Shortest Distance to Target String in a Circular Array

You are given a 0-indexed circular array of strings words and a target string target. A circular array means that the last element connects to the first one. For any index i, the next element is words[(i + 1) % n] and the previous element is words[(i - 1 + n) % n], where n is the length of the array. Starting at startIndex, you can move to either the next or previous word with one step at a time. Your goal is to find the minimum distance needed to reach the target string from the starting index. If target does not exist in the array, return -1.

Leetcode 2516: Take K of Each Character From Left and Right

You are given a string s consisting of the characters ‘a’, ‘b’, and ‘c’, and a non-negative integer k. Each minute, you can choose to take either the leftmost or the rightmost character from s. Your task is to determine the minimum number of minutes required to collect at least k occurrences of each character (‘a’, ‘b’, and ‘c’). If it is not possible to collect k of each character, return -1.

Leetcode 2522: Partition String Into Substrings With Values at Most K

Given a string s consisting of digits between 1 and 9, and an integer k, you need to partition the string into the fewest possible substrings such that the value of each substring is less than or equal to k. Each substring must consist of contiguous digits and must be interpreted as an integer. If it’s not possible to partition the string in such a way, return -1.

Leetcode 2531: Make Number of Distinct Characters Equal

You are given two strings, word1 and word2. In each move, you swap one character from word1 with one from word2. Determine if it is possible to make the number of distinct characters in both strings equal with exactly one swap.

Leetcode 2546: Apply Bitwise Operations to Make Strings Equal

You are given two binary strings s and target of the same length. You can perform an operation on s any number of times to transform it into target. The operation replaces two distinct indices with logical operations. Return true if it’s possible to make s equal to target, otherwise return false.