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 3075. Maximize Happiness of Selected Children

Table of ContentsDescription: Maximize Happiness of Selected ChildrenExample 1Example 2Example 3ConstraintsSolutionTime ComplexitySpace Complexity Source: https://leetcode.com/problems/maximize-happiness-of-selected-children/description/ Description: Maximize Happiness of Selected Children You are given an array happiness of length n, and a positive integer k. There are n children standing in a queue, where the ith child has happiness value happiness[i]. You want to select k children from these n children in k turns. In each turn, when you select a child, the happiness ...

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 2487. Remove Nodes From Linked List

Table of ContentsDescription: Remove Nodes From Linked ListExample 1Example 2ConstraintsSolutionTime ComplexitySpace Complexity Description: Remove Nodes From Linked List You are given the head of a linked list. Remove every node which has a node with a greater value anywhere to the right side of it. Return the head of the modified linked list. Example 1 <strong>Input:</strong> head = [5,2,13,3,8] <strong>Output:</strong> ...

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 ...