All Posts

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 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 2850: Minimum Moves to Spread Stones Over Grid

You are given a 3x3 grid representing stones placed in each cell. In one move, you can move a stone from its current cell to an adjacent cell. The goal is to place one stone in each cell, minimizing the number of moves.

Leetcode 2900: Longest Unequal Adjacent Groups Subsequence I

You are given two arrays: words (a list of distinct strings) and groups (a binary array where each element corresponds to an entry in words). Your task is to select the longest alternating subsequence of words, where each consecutive word has a different corresponding group value. For each pair of consecutive words in the subsequence, the corresponding values in groups must be different.

Leetcode 2901: Longest Unequal Adjacent Groups Subsequence II

You are given an array of strings words and an array groups of equal length n. The task is to find the longest subsequence from words such that the corresponding elements in groups are unequal for adjacent elements in the subsequence, and the Hamming distance between consecutive strings in the subsequence is exactly 1. A string’s Hamming distance with another string is the number of positions at which their characters differ. The subsequence should be returned as an array of strings in the order of the subsequence indices.

Leetcode 2915: Length of the Longest Subsequence That Sums to Target

You are given an array of integers nums and a target sum target. Your task is to find the length of the longest subsequence from nums that sums up to target. A subsequence can be derived by deleting some or no elements from nums while maintaining the original order of the remaining elements. If no such subsequence exists, return -1.