分类
Develop Java 算法

Leetcode: Nested List Weight Sum II

Given a nested list of integers, return the sum of all […]

分类
Develop Java ruby on rails 算法

Leetcode: Factor Combinations

Numbers can be regarded as product of its factors. For […]

分类
Develop ruby on rails 算法

Leetcode: Binary Search

Given a sorted (in ascending order) integer array nums […]

分类
Develop ruby on rails 算法

Leetcode: Implement Trie (Prefix Tree)

Implement a trie with insert, search, and startsWith me […]

分类
Develop Java 算法

Leetcode: Min Stack

Design a stack that supports push, pop, top, and retrie […]

分类
C++ Develop 算法

Leetcode: Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted […]

分类
Develop ruby on rails 算法

Leetcode: Encode and Decode TinyURL

TinyURL is a URL shortening service where you enter a U […]

分类
C++ Develop 算法

Leetcode: LRU Cache

Design and implement a data structure for Least Recentl […]

分类
Develop 算法

Leetcode: Word Ladder II

Question Given two words (beginWord and endWord), and a […]

分类
C++ Develop ruby on rails 算法

Leetcode: Valid Number

Question Validate if a given string is numeric. Some ex […]

分类
C++ Develop 算法

Leetcode: Palindrome Number

Problem Leetcode link for this question Determine wheth […]

分类
C++ Develop 算法

Leetcode: String to Integer (atoi)

Problem Leetcode link Implement atoi to convert a strin […]

分类
C++ Develop 算法

Leetcode: Contains Duplicate II

Question Contains Duplicate II Given an array of intege […]

分类
Develop 算法

Leetcode: Integer to Roman

Question: Integer to Roman Given an integer, convert it […]

分类
Develop 算法

LeetCode: Reverse Integer

Previous Post This is the previous post on same questio […]

分类
Develop 算法

LeetCode: ZigZag Conversion

Previous post This is the old post on this question, us […]

分类
C++ Develop 算法

LeetCode Problem: Maximum Depth of Binary Tree

Recursively count the depth of tree node. One node&#821 […]

分类
C++ Develop 算法

LeetCode Problem: Valid Palindrome

To solving this problem, using two pointer to track the […]

分类
C++ Develop 算法

LeetCode Problem: Pascal’s Triangle II

Follow the algorithm in LeetCode Problem: Pascal’s Tria […]

分类
C++ Develop 算法

LeetCode Problem: Pascal’s Triangle

The problem is simple, each element in the triangle is […]

分类
C++ Develop 算法

Red-Balck Tree

红黑树 是一颗比较平衡的二叉搜索树,算法复杂,但是保证了各种操作最差情况下是O(logn) 定义 除了普通二叉 […]

分类
C++ Develop 算法

Algorithm Problem: Find Out the Minimum Number that Great or Equal to a Given Number In BST

Given a BST and a Number k, find out the minimum number […]

分类
C++ Develop 算法

Algorithm Problem: In-Place Merge Sort

The original merge sort version will take O(n) space, a […]

分类
C++ Develop 算法

LeetCode Problem: Populating Next Right Pointers in Each Node II

The code in the previous article LeetCode Problem: Popu […]

分类
C++ Develop 算法

LeetCode Problem: Populating Next Right Pointers in Each Node, Level traversal of binary tree

It’s easy to doing this by using a queue, doing a […]

分类
C++ Develop 算法

Algorithm Problem: Longest Non-Descending Sub Array or Logest Increasing Subarray, Dynamic programming

The ordinary dynamic programing gives our an algorithm […]

分类
C++ Develop 算法

Algoritm Problem: Add Two Unsigned Integers

To add two unsigned integers, A and B, we can exam a bi […]

分类
C++ Develop 算法

Algorithm Problems: Two Sum

Manage two pointer to the array, one from the front, mo […]

分类
C++ Develop 算法

Algorithm Problem:Swap the left and right sub-tree in a binary tree without recursion

Just swap the tree nodes’ left and right child, i […]

分类
C++ Develop 算法

Algorithm Problem:Intersection of Sorted Array

Binary search every element of arr1 in arr0, if find, a […]

分类
C++ Develop 算法

LeetCode Problem:Flatten Binary Tree to Linked List

We can notice that in the flattened tree, each sub node […]

分类
C++ Develop 算法

Algorithm Sqrt for Double

The binary divide is straight forward solution, but som […]

分类
C++ Develop 算法

Algorithm Problem: Coins,Integer Bag Problem using Dynamic Programming

We can calculate the result by dynamic programming. Whe […]

分类
C++ Develop 算法

LeetCode Problem:Distinct Subsequences

(2013-1-5更新了动态规划版本,见下面) 这题有点复杂,一开始拿到都不知道怎么下手。 尝试的路径是: 1 […]

分类
C++ Develop 算法

题目:Max Ascending

问题比较简单,就是一个数组a[n] 求max(ai-aj), i<j. 从前往后扫描,记录下当前的最小值 […]

分类
C++ Develop 算法

LeetCode题目:Convert Sorted List to Binary Search Tree

问题比上一个难一点,如果是可以用O(n)空间的话,倒是可以开一个数组放上这n个数,然后按上一个问题的解法去做。 […]

分类
C++ Develop 算法

LeetCode题目:Convert Sorted Array to Binary Search Tree

对排序的数组进行二分查找样式的遍历就行了。 Convert Sorted Array to Binary Se […]

分类
C++ Develop 算法

LeetCode题目:Construct Binary Tree from Inorder and Postorder Traversal

这题和上一道题类似,也是首先在postorder中,最后那一个肯定是整棵树的根,然后在inorder中查找这个 […]

分类
C++ Develop 算法

LeetCode题目:Construct Binary Tree from Preorder and Inorder Traversal

这曾经是一道很难的题目,看来这一阵的锻炼确实是有效果的。 方法是,画一棵树出来,比如: 1 / \ 2 3 \ […]

分类
C++ Develop 算法

LeetCode题目:Binary Tree Zigzag Level Order Traversal

比较简单,广度优先变一下就可以了,用一个bool记录是从左到右还是从右到左,每一层结束就翻转一下。 Binar […]