All Posts

Leetcode 2055: Plates Between Candles

You are tasked with processing a string of plates (’*’) and candles (’|’) arranged on a table. For a set of queries, you must determine the number of plates that are enclosed by candles within specified substrings of the string.

Leetcode 2064: Minimized Maximum of Products Distributed to Any Store

You are given a number n representing the number of retail stores and an array of integers quantities. Each quantity[i] represents the number of products of the i-th product type available. The task is to distribute all the products to the stores in such a way that no store gets more than one product type, but may receive any quantity of that type. The goal is to minimize the maximum number of products assigned to any store. Return the smallest possible value of this maximum number of products assigned to a store.

Leetcode 2070: Most Beautiful Item for Each Query

You are given a list of items, where each item has a price and a beauty score. You are also given a list of price queries. For each query, find the maximum beauty of an item with a price less than or equal to the query price. If no such item exists, return 0.

Leetcode 2080: Range Frequency Queries

Design a data structure that allows you to efficiently find the frequency of a given value in a subarray. Implement the class RangeFreqQuery with the following methods:

  • RangeFreqQuery(int[] arr) initializes the data structure.
  • int query(int left, int right, int value) returns the frequency of value in the subarray from left to right.

Leetcode 2187: Minimum Time to Complete Trips

You are given an array ’time’ where each element ’time[i]’ represents the time taken by the ith bus to complete a trip. Your task is to calculate the minimum amount of time required for all buses to complete at least ’totalTrips’ trips in total. Each bus can complete multiple trips consecutively.

Leetcode 2226: Maximum Candies Allocated to K Children

You are given a 0-indexed integer array candies, where each element represents the number of candies in a pile. You also have an integer k, which is the number of children. You need to distribute the candies into k piles such that each child gets the same number of candies. Each child can receive at most one pile, and some piles may go unused. Your task is to return the maximum number of candies each child can receive.