All Posts

Leetcode 2008: Maximum Earnings From Taxi

You are driving a taxi along a road with n points. Each point represents a location on the road. Passengers request rides from one point to another, and for each ride, you earn the distance traveled plus a tip. Your goal is to maximize your earnings by picking up passengers optimally. You can only carry one passenger at a time, and may pick up a new passenger at any point after dropping off the previous one.

Leetcode 2054: Two Best Non-Overlapping Events

Find the maximum sum of values you can achieve by attending at most two non-overlapping events.

Leetcode 2063: Vowels of All Substrings

You are given a string word consisting of lowercase English letters. Your task is to return the total sum of the number of vowels (‘a’, ’e’, ‘i’, ‘o’, and ‘u’) present in every possible substring of word. A substring is any contiguous sequence of characters in the word.

Leetcode 2086: Minimum Number of Food Buckets to Feed the Hamsters

You are given a string representing hamster positions. The string consists of ‘H’ for a hamster and ‘.’ for an empty space. You must place food buckets in empty positions such that all hamsters are fed. A hamster is fed if a food bucket is placed at one of its adjacent positions. Your task is to return the minimum number of food buckets required to feed all the hamsters. If it is impossible, return -1.

Leetcode 2100: Find Good Days to Rob the Bank

You are planning a bank robbery with a gang of thieves. You are given a list, ‘security’, where each element represents the number of guards present on duty each day. You are also given an integer, ’time’, which represents the number of days before and after the current day that must have specific guard arrangements for it to be a good day for the robbery. A good day to rob the bank is defined as:

  1. There must be at least ’time’ days before and after the current day.
  2. The number of guards on the days before the current day must be non-increasing.
  3. The number of guards on the days after the current day must be non-decreasing. Return a list of all the days that are good days to rob the bank.

Leetcode 2110: Number of Smooth Descent Periods of a Stock

You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day. A smooth descent period of a stock consists of contiguous days such that the price on each day decreases by exactly 1 from the previous day. The first day of the period can be a single-day smooth descent. Return the total number of smooth descent periods.