Solved! Leetcode 1431. Kids With the Greatest Number of Candies

source: https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/description/ Kids With the Greatest Number of Candies There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have. Return a boolean array result of length n, ...

Solved! Leetcode 2390. Removing Stars From a String

source: https://leetcode.com/problems/removing-stars-from-a-string/description/ Removing Stars From a String You are given a string s, which contains stars *. In one operation, you can: Choose a star in s. Remove the closest non-star character to its left, as well as remove the star itself. Return the string after all stars have been removed. Note: The input will ...

Solved! Leetcode 2405. Optimal Partition of String

source: https://leetcode.com/problems/optimal-partition-of-string/description/ Optimal Partition of String Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a single substring more than once. Return the minimum number of substrings in such a partition. Note that each character should belong ...

Solved Leetcode 245. Shortest Word Distance III

source: https://leetcode.com/problems/shortest-word-distance-iii/description/ Shortest Word Distance III Given an array of strings wordsDict and two strings that already exist in the array word1 and word2, return the shortest distance between the occurrence of these two words in the list. Note that word1 and word2 may be the same. It is guaranteed that they represent two individual ...

Solved! Leetcode 881. Boats to Save People

source: https://leetcode.com/problems/boats-to-save-people/description/ Boats to Save People You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at most two people at the same time, provided the sum of the weight of ...

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 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 958. Check Completeness of a Binary Tree

Table of ContentsProblem descriptionCheck Completeness of a Binary TreeJavaTime ComplexitySpace ComplexityPythonApproach 1Approach 2 Problem description source: https://leetcode.com/problems/check-completeness-of-a-binary-tree/description/ Check Completeness of a Binary Tree Given the root of a binary tree, determine if it is a complete binary tree. In a complete binary tree, every level, except possibly the last, is completely filled, and all nodes ...

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

Solved! Leetcode 2492. Minimum Score of a Path Between Two Cities

source: https://leetcode.com/problems/minimum-score-of-a-path-between-two-cities/ Minimum Score of a Path Between Two Cities You are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads where roads[i] = [ai, bi, distancei] indicates that there is a bidirectional road between cities ai and bi with a distance equal ...