All Posts

Leetcode 2824: Count Pairs Whose Sum is Less than Target

You are given a 0-indexed integer array nums and an integer target. Return the number of distinct pairs (i, j) such that 0 <= i < j < n and nums[i] + nums[j] < target.

Leetcode 2826: Sorting Three Groups

You are given an array nums containing elements that are either 1, 2, or 3. In each operation, you can remove an element from the array. The task is to return the minimum number of operations required to make the array non-decreasing.

Leetcode 2828: Check if a String Is an Acronym of Words

Given an array of strings words and a string s, determine if s is an acronym of words. The string s is considered an acronym of words if it can be formed by concatenating the first character of each string in words in order.

Leetcode 2830: Maximize the Profit as the Salesman

You are a salesman with n houses placed on a number line, numbered from 0 to n-1. You are given a list of offers where each offer is of the form [start, end, gold], indicating that a buyer wants to purchase all houses from index start to end (inclusive) for gold amount of gold. Your task is to maximize your total earnings by strategically selecting offers such that no two buyers purchase the same house.

Leetcode 2831: Find the Longest Equal Subarray

You are given a list of integers nums and an integer k. Your task is to find the length of the longest subarray where all the elements are equal after you delete at most k elements.

Leetcode 2841: Maximum Sum of Almost Unique Subarray

You are given an integer array nums and two positive integers m and k. Return the maximum sum out of all almost unique subarrays of length k in nums. A subarray is almost unique if it contains at least m distinct elements. If no such subarray exists, return 0.