All Posts

Leetcode 1959: Minimum Total Space Wasted With K Resizing Operations

You are tasked with designing a dynamic array where the number of elements that should be in the array at each time is provided in an integer array nums. Additionally, you are given an integer k, representing the maximum number of times you can resize the array. At each time step, the array’s size must be large enough to hold the elements in nums[i] and any extra space will be wasted. Your goal is to minimize the total wasted space by resizing the array at most k times.

Leetcode 1976: Number of Ways to Arrive at Destination

You are in a city with n intersections, and roads connecting them with specific travel times. Your task is to find the number of different ways you can travel from intersection 0 to intersection n-1 in the shortest time possible. Since the result could be large, return it modulo (10^9 + 7).

Leetcode 1981: Minimize the Difference Between Target and Chosen Elements

You are given an m x n integer matrix, where each row contains n integers. You are also given a target integer. Your task is to choose one integer from each row of the matrix such that the absolute difference between the target and the sum of the chosen elements is minimized. Return the minimum absolute difference.

Leetcode 1986: Minimum Number of Work Sessions to Finish the Tasks

You are assigned several tasks, each with a specified time required to complete. A work session allows you to work continuously for up to sessionTime consecutive hours before taking a break. Your goal is to determine the minimum number of work sessions required to complete all tasks under the following conditions:

  • If a task is started in a session, it must be completed within that same session.
  • You may complete the tasks in any order.
  • You can begin a new task immediately after finishing the previous one.

Return the minimum number of work sessions needed to complete all tasks.

Leetcode 1997: First Day Where You Have Been in All the Rooms

You are given a list of rooms and their visiting order for each day based on a set of rules. On each day, you either revisit a room based on the number of visits or proceed to the next room in a cyclic manner. Your task is to find the first day when all rooms have been visited.

Leetcode 2002: Maximum Product of the Length of Two Palindromic Subsequences

Given a string s, find two disjoint palindromic subsequences such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index.