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 1552: Magnetic Force Between Two Balls

You are given n baskets with distinct positions, and m balls to place in them. The magnetic force between two balls at positions x and y is |x - y|. The goal is to place the balls into baskets such that the minimum magnetic force between any two balls is maximized.

Leetcode 1559: Detect Cycles in 2D Grid

Given a 2D grid of characters, find if there exists a cycle where the same character repeats in the grid. A cycle is defined as a path where a character appears 4 or more times, forming a loop that starts and ends at the same cell. The cycle must consist of adjacent cells, and you are not allowed to revisit the previous cell.

Leetcode 1561: Maximum Number of Coins You Can Get

You and two friends are given 3n piles of coins, and in each step, three piles are chosen. Alice always picks the pile with the most coins, you pick the second largest pile, and your friend Bob picks the remaining pile. Repeat this process until all piles are picked. Your goal is to maximize the total number of coins you can collect.

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 1567: Maximum Length of Subarray With Positive Product

Given an array of integers, your task is to find the maximum length of a contiguous subarray where the product of all its elements is positive. The product of a subarray is considered positive if the result of multiplying all elements of the subarray results in a positive number.