原创 Trapping Rain Water (Java)

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water i

原创 Fraction to Recurring Decimal (Java)

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If

原创 Jump Game II (Java)

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element i

原创 Search in Rotated Sorted Array (Java)

Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7

原创 Distinct Subsequences (Java)

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a

原创 Maximum Gap (Java)

Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve

原创 Recover Binary Search Tree (Java)

Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. N

原创 Populating Next Right Pointers in Each Node II (Java)

Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree

原创 Best Time to Buy and Sell Stock III (Java)

Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find t

原创 Simplify Path (Java)

Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/..

原创 Copy List with Random Pointer (Java)

A linked list is given such that each node contains an additional random pointer which could point to any node in the

原创 N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other

原创 Binary Search Tree Iterator (Java)

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.

原创 N-Queens II (Java)

Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct sol

原创 Reverse Nodes in k-Group (Java)

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of n