PROBLEM DESCRIPTION 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. Return the total sum of all root-to-leaf num...
Flatten Binary Tree to Linked List
PROBLEM DESCRIPTION Given the root of a binary tree, flatten the tree into a “linked list”: The “linked list” should use the same TreeNode class where the right child pointer points to the nex...
Populating Next Right Pointers in Each Node II
PROBLEM DESCRIPTION Given a binary tree struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right node. If there is no next rig...
Partition List
PROBLEM DESCRIPTION Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relat...
Add Binary
PROBLEM DESCRIPTION Given two binary strings a and b, return their sum as a binary string. leetcode SOLUTION class Solution { public String addBinary(String a, String b) { // ...
Remove Duplicates from Sorted List II
PROBLEM DESCRIPTION Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as wel...
Reverse Linked List II
PROBLEM DESCRIPTION Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return th...
Basic Calculator
PROBLEM DESCRIPTION Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation. Note: You are not allowed to use any bui...
Simplify Path
PROBLEM DESCRIPTION Given a string path, which is an absolute path (starting with a slash ‘/’) to a file or directory in a Unix-style file system, convert it to the simplified canonical path. In ...
Valid Parentheses
PROBLEM DESCRIPTION Given a string s containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. An input string is valid if: Open brackets must be...