All Posts

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 2856: Minimum Array Length After Pair Removals

You are given a non-decreasing sorted integer array. Perform operations to remove pairs of elements where nums[i] < nums[j] and return the minimum length of the array after the operations.

Leetcode 2861: Maximum Number of Alloys

You are running a company that manufactures alloys using various types of metals. There are n different metal types available, and you have k machines that can be used to create alloys. Each machine requires a specific amount of each metal type to create an alloy. The i-th machine requires composition[i][j] units of metal type j. You have stock[i] units of metal type i, and purchasing one unit of metal type i costs cost[i] coins. Your task is to maximize the number of alloys you can produce while staying within a budget of budget coins. Each alloy must be made using the same machine.