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 2331. Evaluate Boolean Binary Tree

Table of ContentsDescription: Evaluate Boolean Binary Example 1Example 2ConstraintsSolutionTime ComplexitySpace Complexity Description: Evaluate Boolean Binary You are given the root of a full binary tree with the following properties: Leaf nodes have either the value 0 or 1, where 0 represents False and 1 represents True. Non-leaf nodes have either the value 2 or 3, where 2 represents the boolean OR and 3 represents the boolean AND. The evaluation of a node is as follows: If the node is a leaf node, the ...

Solved! Leetcode 2816. Double a Number Represented as a Linked List

Table of ContentsDescription: Double a Number Represented as a Linked ListExample 1Example 2ConstraintsSolutionTime ComplexitySpace Complexity Description: Double a Number Represented as a Linked List You are given the head of a non-empty linked list representing a non-negative integer without leading zeroes. Return the head of the linked list after doubling it. Example 1 <strong>Input:</strong> head = [1,8,9] <strong>Output:</strong> [3,7,8] <strong>Explanation:</strong> The figure above corresponds ...

Solved! Leetcode 1328. Break a Palindrome

Table of ContentsDescription: Break a PalindromeExample 1Example 2ConstraintsSolutionTime ComplexitySpace Complexity Description: Break a Palindrome Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the lexicographically smallest one possible. Return the resulting string. If there is no way to replace a character ...

Solved! Leetcode 2441. Largest Positive Integer That Exists With Its Negative

Table of ContentsDescription: Largest Positive Integer That Exists With Its NegativeExample 1Example 2Example 3ConstraintsSolutionTime ComplexitySpace Complexity Description: Largest Positive Integer That Exists With Its Negative Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array. Return the positive integer k. If there is no such integer, return -1. Example 1 <strong>Input:</strong> nums = ...

Solved! Leetcode 1529. Minimum Suffix Flips

Table of ContentsDescription: Minimum Suffix FlipsExample 1Example 2Example 3ConstraintsSolutionTime ComplexitySpace Complexity Description: Minimum Suffix Flips You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target. In one operation, you can pick an index i where 0 <= i < n and flip all bits in the inclusive range [i, ...

Solved! Leetcode 2038. Remove Colored Pieces if Both Neighbors are the Same Color

Table of ContentsDescription: Remove Colored Pieces if Both Neighbors are the Same ColorExample 1Example 2Example 3ConstraintsSolutionTime ComplexitySpace Complexity Description: Remove Colored Pieces if Both Neighbors are the Same Color There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the ith piece. Alice and ...

Solved! Leetcode 2000. Reverse Prefix of Word

Table of ContentsDescription: Reverse Prefix of WordExample 1Example 2Example 3ConstraintsSolutionTime ComplexitySpace Complexity Description: Reverse Prefix of Word Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing. For example, if word = "abcdefd" and ch = "d", then you should reverse the segment that starts at 0 and ...

Solved! Leetcode 1507. Reformat Date

Table of ContentsDescription: Reformat DateExample 1Example 2Example 3ConstraintsSolution Description: Reformat Date Given a date string in the form Day Month Year, where: Day is in the set {"1st", "2nd", "3rd", "4th", ..., "30th", "31st"}. Month is in the set {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}. Year is in the range [1900, 2100]. Convert the date string to the ...

Solved! Leetcode 623. Add One Row to Tree

Table of ContentsDescription Add One Row to TreeExample 1Example 2ConstraintsSolutionTime ComplexitySpace Complexity Description Add One Row to Tree Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth. Note that the root node is at depth 1. The adding rule is: Given the integer depth, for each not null tree node cur at ...