All Posts

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 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.

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 1616: Split Two Strings to Make Palindrome

You are given two strings, a and b, of the same length. You need to split both strings at the same index into two parts: one prefix and one suffix for each string. Then, check if concatenating one prefix from one string with the suffix of the other string forms a palindrome. Specifically, you need to check if either aprefix + bsuffix or bprefix + asuffix forms a palindrome.

Leetcode 1712: Ways to Split Array Into Three Subarrays

You are given an array of non-negative integers. Your task is to count the number of ways the array can be split into three contiguous non-empty subarrays: left, mid, and right. The sum of the elements in the left subarray should be less than or equal to the sum in the mid subarray, and the sum of the mid subarray should be less than or equal to the sum of the right subarray. Return the number of such good splits modulo 10^9 + 7.

Leetcode 1721: Swapping Nodes in a Linked List

You are given a singly linked list and an integer k. The task is to swap the values of the kth node from the beginning of the list with the kth node from the end of the list. The list is 1-indexed.