All Posts

Leetcode 1546: Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

Given an integer array nums and an integer target, return the maximum number of non-empty, non-overlapping subarrays that sum up to the target.

Leetcode 1562: Find Latest Group of Size M

You are given a permutation of integers from 1 to n, where each integer represents a position in a binary string of size n that is initially filled with zeros. At each step, you will flip the bit at the position specified by the current element of the array. You are also given an integer m, and your task is to determine the latest step at which there exists a contiguous substring of exactly m ones in the binary string.

Leetcode 1577: Number of Ways Where Square of Number Is Equal to Product of Two Numbers

Given two integer arrays, nums1 and nums2, return the total number of valid triplets that can be formed under two conditions:

Type 1: A triplet (i, j, k) is valid if nums1[i]^2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length. Type 2: A triplet (i, j, k) is valid if nums2[i]^2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.

Leetcode 1590: Make Sum Divisible by P

Given an array of positive integers nums and an integer p, your task is to remove the smallest subarray (contiguous elements) such that the sum of the remaining elements is divisible by p. If it’s impossible, return -1. Note that the entire array cannot be removed.

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 1600: Throne Inheritance

In a kingdom, there is a well-defined hierarchy of inheritance, starting with the king. The inheritance order depends on the family’s birth and death events. Implement a class to keep track of the order, excluding the dead members.