All Posts

Leetcode 1493: Longest Subarray of 1's After Deleting One Element

Given a binary array nums, you should delete one element from it. After deleting one element, return the size of the longest non-empty subarray containing only 1’s in the resulting array. If no such subarray exists, return 0.

Leetcode 1497: Check If Array Pairs Are Divisible by k

You are given an array of integers arr of even length n and an integer k. The task is to check if you can divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k. Return true if it’s possible to divide the array into valid pairs, otherwise return false.

Leetcode 1498: Number of Subsequences That Satisfy the Given Sum Condition

You are given an array of integers nums and an integer target. Your task is to count how many non-empty subsequences of nums exist such that the sum of the minimum and maximum element in each subsequence is less than or equal to target. Return the result modulo 10^9 + 7.

Leetcode 1503: Last Moment Before All Ants Fall Out of a Plank

You are given a wooden plank of length n, and some ants are walking on the plank. Some ants move to the left, others to the right. When two ants meet, they change directions without any additional time loss. When an ant reaches the edge of the plank, it falls off. The task is to determine when the last ant will fall off the plank.

Leetcode 1504: Count Submatrices With All Ones

You are given a binary matrix of size m x n where each element is either 0 or 1. Your task is to count how many submatrices consist entirely of 1s.

Leetcode 1508: Range Sum of Sorted Subarray Sums

You are given an array of positive integers. Compute all possible subarray sums, sort them in non-decreasing order, and return the sum of elements from index left to right in the sorted array modulo 10^9 + 7.