All Posts
Leetcode 2069: Walking Robot Simulation II
A robot is placed on a grid and initially faces East. It is instructed to move forward by a specified number of steps. If the robot attempts to move out of bounds, it turns 90 degrees counterclockwise and tries again. The task is to implement a class for the robot that can handle these movements and return its current position and direction.
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 2075: Decode the Slanted Ciphertext
Given an encoded string and the number of rows used to encode the original text, recover the original string. The encoded text is produced by filling a matrix in a slanted transposition cipher and reading it row by row.
Leetcode 2079: Watering Plants
n
plants arranged in a row. Starting at the river, you water the plants in order, refilling your watering can when it runs out. The goal is to determine the total number of steps to water all the plants.
You need to water 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 ofvalue
in the subarray fromleft
toright
.