All Posts

Leetcode 1578: Minimum Time to Make Rope Colorful

Alice has a rope with balloons arranged in a sequence where each balloon has a color. She wants the rope to be colorful, meaning no two consecutive balloons should have the same color. Bob is tasked with helping Alice by removing some balloons. Each balloon has an associated cost, and Bob needs to minimize the total time spent removing the balloons to achieve the desired colorful sequence. Return the minimum time Bob needs to make the rope colorful.

Leetcode 1594: Maximum Non Negative Product in a Matrix

You are given a m x n matrix grid. Starting at the top-left corner (0, 0), you can only move right or down. Your task is to find the path from the top-left to the bottom-right corner that results in the maximum non-negative product of the grid values along the path. If such a path results in a negative product, return -1. The product is calculated by multiplying all grid values visited along the path. You should return the maximum non-negative product modulo 10^9 + 7.

Leetcode 1621: Number of Sets of K Non-Overlapping Line Segments

You are given n points on a 1-D plane, where each point i is at x = i. Your task is to find the number of ways to draw exactly k non-overlapping line segments that cover two or more points, such that the endpoints are integral. Return the result modulo 10^9 + 7.

Leetcode 1626: Best Team With No Conflicts

You are the manager of a basketball team, and you are tasked with selecting a team that maximizes the overall score. The score of the team is calculated by summing the individual scores of all the selected players. However, there is a rule: a conflict arises if a younger player has a strictly higher score than an older player. There is no conflict if players have the same age.

Leetcode 1638: Count Substrings That Differ by One Character

Given two strings s and t, count the number of ways to choose a non-empty substring of s and replace exactly one character such that the resulting substring becomes a substring of t. In other words, find how many substrings in s differ from substrings in t by exactly one character.

Leetcode 1653: Minimum Deletions to Make String Balanced

You are given a string s consisting of the characters ‘a’ and ‘b’. The goal is to delete the minimum number of characters from s to make it balanced. A string is balanced if no ‘b’ precedes an ‘a’.