All Posts

Leetcode 1593: Split a String Into the Max Number of Unique Substrings

Given a string s, your task is to split it into the maximum number of non-empty substrings such that all substrings are unique. You are allowed to split the string in any way, but each substring in the split must not repeat.

Leetcode 1718: Construct the Lexicographically Largest Valid Sequence

Given an integer n, find a sequence of length 2n - 1 that satisfies the following conditions:

  1. The integer 1 occurs once in the sequence.
  2. Each integer between 2 and n occurs twice in the sequence.
  3. For every integer i between 2 and n, the distance between the two occurrences of i is exactly i.
  4. The sequence should be lexicographically the largest possible sequence.

The sequence is considered lexicographically larger if, at the first position where the two sequences differ, the number in the first sequence is greater.

Leetcode 1774: Closest Dessert Cost

You are planning to make a custom dessert by choosing an ice cream base and toppings. The dessert must follow these rules: You must select one ice cream base. You can add one or more types of toppings, or choose to skip toppings. You can add at most two of each topping type. You are given an array representing the base costs and topping costs. The goal is to create a dessert where the total cost is as close as possible to the target price. If there are multiple dessert combinations that meet the target price, return the lower cost.

Leetcode 1849: Splitting a String Into Descending Consecutive Values

Given a string s consisting of digits, check if it is possible to split it into two or more non-empty substrings such that the numerical values of the substrings are in strictly descending order and the difference between the values of adjacent substrings is exactly 1.

Leetcode 1863: Sum of All Subset XOR Totals

You are given an array of integers nums. The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty. For every subset of nums, calculate the XOR total and return the sum of all XOR totals.

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.