原创 Best Time to Buy and Sell Stock I, II

Best Time to Buy and Sell Stock I Say you have an array for which the ith element is the price of a given stock

原创 Linked List Cycle I II

Linked List Cycle Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without u

原创 Reverse Words

Reverse Words Write a function that reverses the order of the words in a string. For example, your function should tran

原创 Course Schedule

Course Schedule There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may hav

原创 implement a queue using stack

//implement a queue using stack public class Solution { Stack<Integer> stack1 = new Stack<Integer>(); Stack<I

原创 Basic Calculator

Basic Calculator Implement a basic calculator to evaluate a simple expression string. The expression string may

原创 Course Schedule II

Course Schedule II There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may

原创 Remove Duplicates from Sorted Array I, II

Remove Duplicates from Sorted Array II Follow up for "Remove Duplicates": What if duplicates are allowed at most

原创 Ternary Expression

Ternary Expression  a?b:c   a  / \ b   c a?b?c:d:e     a    / \   b   e  / \ c   d a?b:c?d:e    a   / \  b   c     / \

原创 Word Search

Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from lette

原创 Triangle

Triangle Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numb

原创 House Robber

House Robber  You are a professional robber planning to rob houses along a street. Each house has a certain amou

原创 Serialize and Deserialize a binary tree

Serialize and Deserialize a binary tree void Serialize(TreeNode node) { if (node == null) { System.out.print(

原创 N-Queens II

N-Queens II Follow up for N-Queens problem. Now, instead outputting board configurations, return the total numb

原创 House Robber II

House Robber II Note: This is an extension of House Robber. After robbing those houses on that street, the thie