All Posts

Leetcode 2575: Find the Divisibility Array of a String

Given a string word consisting of digits and an integer m, return an array where each element is 1 if the numeric value of the prefix word[0,…,i] is divisible by m, otherwise 0.

Leetcode 2578: Split With Minimum Sum

Given a positive integer num, split it into two non-negative integers num1 and num2 such that the concatenation of num1 and num2 is a permutation of the digits of num. The goal is to minimize the sum of num1 and num2.

Leetcode 2579: Count Total Number of Colored Cells

You are given a 2D array ranges, where each entry ranges[i] = [starti, endi] denotes a range of integers between starti and endi (inclusive). You need to split the ranges into two groups, ensuring that overlapping ranges belong to the same group. Return the total number of ways to split the ranges into two groups modulo (10^9 + 7).

Leetcode 2582: Pass the Pillow

You are given the root of a binary tree and a positive integer k. The level sum in the tree is the sum of the node values that lie at the same level. Return the kth largest level sum in the tree. If there are fewer than k levels, return -1. Nodes are on the same level if they are at the same distance from the root.

Leetcode 2591: Distribute Money to Maximum Children

You are given an integer money and an integer children. You need to distribute the money to the children such that everyone gets at least 1 dollar, nobody gets exactly 4 dollars, and you maximize the number of children receiving exactly 8 dollars. Return the maximum number of children who receive 8 dollars, or -1 if it’s not possible.

Leetcode 2597: The Number of Beautiful Subsets

You are given an array of positive integers nums and a positive integer k. A subset of nums is considered beautiful if it does not contain any two integers whose absolute difference is equal to k. Your task is to return the number of non-empty beautiful subsets of the array nums. A subset is formed by deleting some (possibly none) elements from nums, and two subsets are different if their selected indices are different.