304 North Cardinal St.
Dorchester Center, MA 02124

# Category Leetcode Solution

## Minimum Depth of Binary Tree LeetCode Solution

Problem – Minimum Depth of Binary Tree LeetCode Solution Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A…

## Path Sum II LeetCode Solution

Problem – Path Sum II LeetCode Solution Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of the node values in the path equals targetSum. Each path should be returned as a list of the node values, not node…

## Distinct Subsequences LeetCode Solution

Problem – Distinct Subsequences LeetCode Solution Given two strings s and t, return the number of distinct subsequences of s which equals t. A string’s subsequence is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the remaining characters’…

## Triangle LeetCode Solution

Problem – Triangle LeetCode Solution 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…

## Best Time to Buy and Sell Stock III LeetCode Solution

Problem – Best Time to Buy and Sell Stock III LeetCode Solution You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete at most two transactions. Note: You may…

## Word Ladder II LeetCode Solution

Problem – Word Ladder II LeetCode Solution A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> … -> sk such that: Every adjacent pair of words differs by a single letter. Every si for 1 <= i <= k is in wordList.…

## Sum Root to Leaf Numbers LeetCode Solution

Problem – Sum Root to Leaf Numbers LeetCode Solution You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number. For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123. Return the…

## Palindrome Partitioning II LeetCode Solution

Problem – Palindrome Partitioning II LeetCode Solution Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. Example 1: Example 2: Example 3: Constraints: 1 <= s.length <= 2000…

## Gas Station LeetCode Solution

Problem – Gas Station LeetCode Solution There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its…

## Candy LeetCode Solution

Problem – Candy LeetCode Solution There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings. You are giving candies to these children subjected to the following requirements: Each child must have at…