All Posts

Leetcode 1744: Can You Eat Your Favorite Candy on Your Favorite Day?

You are given an array candiesCount where each element represents the number of candies of a particular type. You are also given a set of queries, each asking whether it’s possible to eat a candy of a certain type on a specific day without exceeding a daily candy limit. You must follow these game rules:

  • You start eating candies on day 0.
  • You cannot eat candies of type i until you have eaten all candies of type i-1.
  • You must eat at least one candy per day.

Your task is to return an array of booleans where each element indicates whether it’s possible to eat a candy of the specified type on the given day, subject to the daily cap.

Leetcode 1749: Maximum Absolute Sum of Any Subarray

Given an array of integers nums, your task is to find the maximum absolute sum of any subarray. The absolute sum of a subarray is the absolute value of the sum of its elements.

Leetcode 1750: Minimum Length of String After Deleting Similar Ends

You are given a string s consisting of only the characters ‘a’, ‘b’, and ‘c’. Your task is to repeatedly perform the following operation any number of times:

  1. Pick a non-empty prefix from the string where all characters are equal.
  2. Pick a non-empty suffix from the string where all characters are equal.
  3. The prefix and suffix should not intersect, and the characters in both should be the same.
  4. Remove the prefix and suffix.

Your goal is to find the minimum length of the string after performing the operation any number of times.

Leetcode 1753: Maximum Score From Removing Stones

You are given three piles of stones, with sizes a, b, and c respectively. In each turn, you can choose two different non-empty piles, remove one stone from each, and add 1 point to your score. The game stops when there are fewer than two non-empty piles left, meaning no more valid moves are available. Your task is to return the maximum score you can achieve.

Leetcode 1754: Largest Merge Of Two Strings

You are given two strings, word1 and word2. You need to construct a string merge by choosing characters from both strings. At each step, you can either append the first character of word1 to merge (if word1 is non-empty) or append the first character of word2 to merge (if word2 is non-empty). The goal is to form the lexicographically largest string possible from these choices.

Leetcode 1759: Count Number of Homogenous Substrings

Given a string s consisting of lowercase letters, your task is to find the total number of homogenous substrings in s. A homogenous substring is a substring where all characters are the same. Since the result could be very large, return the total modulo 10^9 + 7.