All Posts
Leetcode 2087: Minimum Cost Homecoming of a Robot in a Grid
You are given a grid of size m x n and two positions: the robot’s starting position (startPos) and its home position (homePos). The robot can move left, right, up, or down, with associated costs for moving to new rows and columns. Calculate the minimum total cost for the robot to move from its start position to its home position.
Leetcode 2090: K Radius Subarray Averages
Given an array of integers, you need to compute the k-radius average for each element in the array. The k-radius average for an element at index i is the average of the elements from index i - k to i + k (inclusive). If there are fewer than k elements before or after the index i, the result for that index will be -1.
Leetcode 2091: Removing Minimum and Maximum From Array
You are given an array of distinct integers. Your task is to remove the elements that hold the minimum and maximum values in the array. A deletion can either be from the front or the back of the array. Your objective is to find the minimum number of deletions required to remove both of these elements.
Leetcode 2099: Find Subsequence of Length K With the Largest Sum
You are given an integer array ’nums’ and an integer ‘k’. You need to find a subsequence of ’nums’ of length ‘k’ such that the sum of its elements is maximized. A subsequence is a sequence that can be derived from another array by deleting some or no elements without changing the order of the remaining elements. Return any subsequence with the largest sum.
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:
- There must be at least ’time’ days before and after the current day.
- The number of guards on the days before the current day must be non-increasing.
- 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.