All Posts

Leetcode 1915: Number of Wonderful Substrings

A string is considered wonderful if at most one letter appears an odd number of times. Given a string word consisting of the first ten lowercase English letters (‘a’ through ‘j’), return the total number of wonderful non-empty substrings in the string word. If the same substring appears multiple times, each occurrence should be counted separately.

Leetcode 1930: Unique Length-3 Palindromic Subsequences

You are given a string s, and you need to return the number of unique palindromic subsequences of length 3 that are subsequences of s.

Leetcode 1947: Maximum Compatibility Score Sum

You are given a survey with n questions where each question’s answer is either 0 (no) or 1 (yes). The survey is completed by m students and m mentors. Each student’s answers are represented by a 2D array of size m x n, and similarly, each mentor’s answers are represented by another 2D array. The compatibility score of a student-mentor pair is calculated as the number of answers that are the same for both the student and the mentor. Your task is to find the optimal pairing of students to mentors that maximizes the sum of the compatibility scores.

Leetcode 1986: Minimum Number of Work Sessions to Finish the Tasks

You are assigned several tasks, each with a specified time required to complete. A work session allows you to work continuously for up to sessionTime consecutive hours before taking a break. Your goal is to determine the minimum number of work sessions required to complete all tasks under the following conditions:

  • If a task is started in a session, it must be completed within that same session.
  • You may complete the tasks in any order.
  • You can begin a new task immediately after finishing the previous one.

Return the minimum number of work sessions needed to complete all tasks.

Leetcode 2002: Maximum Product of the Length of Two Palindromic Subsequences

Given a string s, find two disjoint palindromic subsequences such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index.

Leetcode 2044: Count Number of Maximum Bitwise-OR Subsets

Given an integer array nums, find the maximum bitwise OR that can be achieved by any subset of nums and count how many different non-empty subsets yield this maximum value. A subset is defined as any combination of elements from the array, and subsets are considered different if their elements are selected from different indices.