All Posts

Leetcode 1513: Number of Substrings With Only 1s

Given a binary string s, return the number of substrings that consist entirely of ‘1’s. Since the result can be large, return the answer modulo (10^9 + 7).

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 1551: Minimum Operations to Make Array Equal

Given an integer n, create an array arr of length n where arr[i] = (2 * i) + 1. You can perform operations to make all elements in the array equal, with the goal of minimizing the number of operations.

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 1573: Number of Ways to Split a String

Given a binary string, you need to split it into three non-empty parts such that each part contains the same number of ‘1’s. You must return the total number of ways to split the string, with the result modulo 10^9 + 7.

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.