Algorithm
Stone Game VI
Comments CountDescription
Sum of Absolute Differences in a sorted Array
Comments CountDescription
Max Number of K-Sum Pairs
Comments CountDescription
Goal Parser Interpretation
Comments CountDescription
You own a Goal Parser that can interpret a string command. The command consists of an alphabet of “G”, “()” and/or “(al)” in some order. The Goal Parser will interpret “G” as the string “G”, “()” as the string “o”, and “(al)” as the string “al”. The interpreted strings are then concatenated in the original order.
Partitioning into Minimum Number of Deci-Binary Numbers
Comments CountDescription
A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not.
Count of Matches in Tournament
Comments CountDescription
You are given an integer n, the number of teams in a tournament that has strange rules:
Jump Game VI
heap algorithm dynamic programming
Comments CountDescription
You are given a 0-indexed integer array nums and an integer k.
Maximum Erasure Value
Comments CountDescription
Minimum Cost Tree From Leaf Values
Comments CountProblem description
Given an array arr of positive integers, consider all binary trees such that: Each node has either 0 or 2 children; The values of arr correspond to the values of each leaf in an in-order traversal of the tree. (Recall that a node is a leaf if and only if it has 0 children.) The value of each non-leaf node is equal to the product of the largest leaf value in its left and right subtree respectively. Among all possible binary trees considered, return the smallest possible sum of the values of each non-leaf node. It is guaranteed this sum fits into a 32-bit integer.
Shortest path with alternating colors
algorithm breadth first search
Comments CountProblem description
Consider a directed graph, with nodes labelled 0, 1, …, n-1. In this graph, each edge is either red or blue, and there could be self-edges or parallel edges.
Smallest Sufficient Team
algorithm NP Hard dynamic programming
Comments CountProblem description
In a project, you have a list of required skills req_skills, and a list of people. The i-th person people[i] contains a list of skills that person has.
Car Pooling
Comments CountProblem description
You are driving a vehicle that has capacity empty seats initially available for passengers. The vehicle only drives east (ie. it cannot turn around and drive west.)
Find in Mountain Array
leetcode algorithm binary search
Comments CountProblem description
(This problem is an interactive problem.)
Letter Tile Possibilities
Comments CountProblem description
Island Perimeter
Comments CountProblem description
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water.
Number of Islands
leetcode algorithm depth first search
Comments CountProblem description
Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
Surrounded Regions
leetcode algorithm depth first search
Comments CountProblem description
Given a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’.
Convert Sorted List to Binary Search Tree
leetcode algorithm binary search tree linked list
Comments CountProblem description
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
Shortest Common Supersequence
leetcode algorithm dynamic programming
Comments CountProblem description
Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If multiple answers exist, you may return any of them.
Gas Station
Comments CountThere are N gas stations along a circular route, where the amount of gas at station i is gas[i].
Smallest Subtree with all the Deepest Nodes (LC865)
leetcode algorithm binary tree depth first search
Comments CountProblem description
Given a binary tree rooted at root, the depth of each node is the shortest distance to the root.
All Nodes Distance K in Binary Tree (LC863)
leetcode algorithm depth first search binary tree
Comments CountProblem description
We are given a binary tree (with root node root), a target node, and an integer value K.
Sum of Distances in Tree (LC834)
leetcode algorithm depth first search tree
Comments CountProblem description
An undirected, connected tree with N nodes labelled 0…N-1 and N-1 edges are given.
Partition Array for Maximum Sum (LC1043)
dynamic programming leetcode algorithm
Comments CountProblem description
Given an integer array A, you partition the array into (contiguous) subarrays of length at most K. After partitioning, each subarray has their values changed to become the maximum value of that subarray.
Robot Bounded In Circle (LC1041)
Comments CountProblem description
On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions:
Binary Tree Pruning (LC814)
leetcode algorithm binary tree depth first search post order traversal
Comments CountProblem description
We are given the head node root of a binary tree, where additionally every node’s value is either a 0 or a 1.
Minimum Distance Between BST Nodes (LC783)
leetcode algorithm in order traversal binary tree
Comments CountProblem description
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.
Insert into Binary Search Tree (LC701)
algorithm leetcode depth first search binary tree
Comments CountProblem description
Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST.
Print Binary Tree (LC655)
binary tree recursion depth first search leetcode algorithm
Comments CountProblem description
Print a binary tree in an m*n 2D string array following these rules:
Course Schedule II (LC210)
leetcode algorithm topological sort breadth first search depth first search
Comments CountProblem description
There are a total of n courses you have to take, labeled from 0 to n-1.
Course Schedule (LC207)
leetcode algorithm topological sort depth first search breadth first search
Comments CountProblem description
There are a total of n courses you have to take, labeled from 0 to n-1.
Find Duplicate Subtrees (LC652)
leetcode algorithm depth first search binary tree
Comments CountProblem description
Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them.
Sum of Left Leaves (LC404)
leetcode algorithm binary tree depth first search tree traversal
Comments CountProblem description
Find the sum of all left leaves in a given binary tree.
House Robber III (LC337)
leetcode algorithm binary tree dynamic programming
Comments CountProblem description
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that “all houses in this place forms a binary tree”. It will automatically contact the police if two directly-linked houses were broken into on the same night.
Serialize and Deserialize Binary Tree (LC297)
leetcode algorithm binary tree
Comments CountProblem description
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.
Lowest Common Ancestor of a Binary Tree (LC236)
leetcode algorithm binary tree recursion
Comments CountProblem description
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
Lowest Common Ancestor of a Binary Search Tree (LC235)
leetcode algorithm binary search tree
Comments CountProblem description
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
Kth Smallest Element in a BST (LC230)
leetcode algorithm binary search tree
Comments CountProblem description
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.
Binary Search Tree Iterator (LC173)
leetcode algorithm binary search tree
Comments CountProblem description
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
Minimum Score Triangulation of Polygon (LC1039)
leetcode algorithm dynamic programming
Comments CountProblem description
Given N, consider a convex N-sided polygon with vertices labelled A[0], A[i], …, A[N-1] in clockwise order.
Binary Search Tree to Greater Sum Tree (LeetCode 1038)
leetcode algorithm binary search tree
Comments CountProblem Description
Given the root of a binary search tree with distinct values, modify it so that every node has a new value equal to the sum of the values of the original tree that are greater than or equal to node.val.
Is Subsequence (LeetCode 392)
algorithm leetcode two pointers
Comments CountProblem description
Given a string s and a string t, check if s is subsequence of t.
Best Time to Buy and Sell Stock (LeetCode 121)
Comments CountProblem Description
Say you have an array for which the ith element is the price of a given stock on day i.
Best Time to Buy and Sell Stock (II) (LeetCode 122)
Comments CountProblem description
Say you have an array for which the ith element is the price of a given stock on day i.
Online stock span (LeetCode 901)
Comments CountProblem description
Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of that stock’s price for the current day.
Base Ball Game (LeetCode 682)
Comments CountProblem description
You’re now a baseball game point recorder.
Delete Node in a BST (LeetCode 450)
Comments CountProblem description
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.
Divide and conqur
Comments CountDivide and conqur is a very powerful scheme that can reduce the original problem into sub-problems, which can be recursively reduced to sub-sub-problems and solved.