Category Leetcode Solution

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…

View Answers

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’…

View Answers

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…

View Answers

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

View Answers

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…

View Answers

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…

View Answers

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…

View Answers

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…

View Answers