All Posts

Leetcode 1477: Find Two Non-overlapping Sub-arrays Each With Target Sum

You are given an array of integers arr and an integer target. You need to find two non-overlapping sub-arrays of arr each with a sum equal target. The goal is to minimize the sum of their lengths, and if no such sub-arrays exist, return -1.

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 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 1524: Number of Sub-arrays With Odd Sum

You are given an array of integers arr. Your task is to count the number of subarrays whose sum is odd. Since the answer can be a large number, return it modulo (10^9 + 7).

Leetcode 1525: Number of Good Ways to Split a String

You are given a string s. You need to determine the number of valid ways to split s into two non-empty substrings such that the number of distinct letters in the left and right substrings is the same.

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.