Solved! Leetcode 1219. Path with Maximum Gold

source: https://leetcode.com/problems/path-with-maximum-gold/description/ Table of ContentsDescription: Path with Maximum GoldExample 1Example 2ConstraintsSolutionTime ComplexitySpace Complexity Description: Path with Maximum Gold In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the ...

Solved! Leetcode 983. Minimum Cost For Tickets

source: https://leetcode.com/problems/minimum-cost-for-tickets/description/ Table of ContentsMinimum Cost For TicketsExample 1Example 2ConstraintsSolution Minimum Cost For Tickets You have planned some train traveling one year in advance. The days of the year you will travel are given as an integer array days. Each day is an integer from 1 to 365. Train tickets are sold in three different ...

Solved! Leetcode 139. Word Break

source: https://leetcode.com/problems/word-break/ Table of ContentsWord BreakDescriptionExample 1:Example 2:Example 3:Constraints:Solution Word Break Description Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation. ...

Solved! Leetcode 863. All Nodes Distance K in Binary Tree

Solved! Leetcode 863. All Nodes Distance K in Binary Tree
source: https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/description/ Table of ContentsAll Nodes Distance K in Binary TreeExample 1:Example 2:Constraints:Solution All Nodes Distance K in Binary Tree Description Given the root of a binary tree, the value of a target node target, and an integer k, return an array of the values of all nodes that have a distance k from the ...

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 879. Profitable Schemes

source: https://leetcode.com/problems/profitable-schemes/description/ Profitable Schemes There is a group of n members, and a list of various crimes they could commit. The ith crime generates a profit[i] and requires group[i] members to participate in it. If a member participates in one crime, that member can’t participate in another crime. Let’s call a profitable scheme any subset ...

Solved! Leetcode 1372. Longest ZigZag Path in a Binary Tree

source: https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree/description/ Longest ZigZag Path in a Binary Tree You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow: Choose any node in the binary tree and a direction (right or left). If the current direction is right, move to the right child of the ...

Solved! Leetcode 120. Triangle

Table of ContentsProblem DescriptionTriangleJavaPython Problem Description source: https://leetcode.com/problems/triangle/description/ Triangle Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either index i ...

Solved! Leetcode 1466. Reorder Routes to Make All Paths Lead to the City Zero

source: https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/description/ Reorder Routes to Make All Paths Lead to the City Zero There are n cities numbered from 0 to n – 1 and n – 1 roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to ...