Solved! Leetcode 1312. Minimum Insertion Steps to Make a String Palindrome

source: https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome/description/ Minimum Insertion Steps to Make a String Palindrome Given a string s. In one step you can insert any character at any index of the string. Return the minimum number of steps to make s palindrome. A Palindrome String is one that reads the same backward as well as forward. Example 1: Input: ...

Solved! Leetcode 1402. Reducing Dishes

Table of ContentsProblem DescriptionReducing DishesJavaPython Problem Description source: https://leetcode.com/problems/reducing-dishes/description/ Reducing Dishes A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time. Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its ...

Solved! Leetcode 646. Maximum Length of Pair Chain

source: https://leetcode.com/problems/maximum-length-of-pair-chain/description/ Maximum Length of Pair Chain You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be formed in this fashion. Return the length ...

Solved! Leetcode 320. Generalized Abbreviation

source: https://leetcode.com/problems/generalized-abbreviation/description/ Generalized Abbreviation A word’s generalized abbreviation can be constructed by taking any number of non-overlapping and non-adjacent substrings and replacing them with their respective lengths. For example, "abcde" can be abbreviated into: "a3e" ("bcd" turned into "3") "1bcd1" ("a" and "e" both turned into "1") "5" ("abcde" turned into "5") "abcde" (no substrings ...

Solved! Leetcode 1255. Maximum Score Words Formed by Letters

source: https://leetcode.com/problems/maximum-score-words-formed-by-letters/description/ Maximum Score Words Formed by Letters Given a list of words, list of single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words formed by using the given letters (words[i] cannot be used two or more times). It is not necessary to use ...

Solved! Leetcode 2477. Minimum Fuel Cost to Report to the Capital

source: https://leetcode.com/problems/minimum-fuel-cost-to-report-to-the-capital/description/ There is a tree (i.e., a connected, undirected graph with no cycles) structure country network consisting of n cities numbered from 0 to n – 1 and exactly n – 1 roads. The capital city is city 0. You are given a 2D integer array roads where roads[i] = [ai, bi] denotes that ...

Solved! Leetcode 1463. Cherry Pickup II

Solved! Leetcode 1463. Cherry Pickup II
source: https://leetcode.com/problems/cherry-pickup-ii/description/ Cherry Pickup II You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell. You have two robots that can collect cherries for you: Robot #1 is located at the top-left corner (0, 0), ...

Solved! Leetcode 2431. Maximize Total Tastiness of Purchased Fruits

source: https://leetcode.com/problems/maximize-total-tastiness-of-purchased-fruits/description/ Maximize Total Tastiness of Purchased Fruits You are given two non-negative integer arrays price and tastiness, both arrays have the same length n. You are also given two non-negative integers maxAmount and maxCoupons. For every integer i in range [0, n – 1]: price[i] describes the price of ith fruit. tastiness[i] describes the ...

Solved! Leetcode 518: Coin Change II

source: https://leetcode.com/problems/coin-change-ii/description/ Coin Change II You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the number of combinations that make up that amount. If that amount of money cannot be made up by any combination of the coins, return 0. You ...

Solved! Leetcode 2361: Minimum Costs Using the Train Line

source: https://leetcode.com/problems/minimum-costs-using-the-train-line/ A train line going through a city has two routes, the regular route and the express route. Both routes go through the same n + 1 stops labeled from 0 to n. Initially, you start on the regular route at stop 0. You are given two 1-indexed integer arrays regular and express, both ...