代码改变世界

Subsets-II

2014-12-22 17:21 by 李涛的技术博客, 127 阅读, 0 推荐, 收藏, 编辑
摘要:Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a subset must be in non-descending ord... 阅读全文

Subsets

2014-12-22 16:49 by 李涛的技术博客, 147 阅读, 0 推荐, 收藏, 编辑
摘要:Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must no... 阅读全文

算法归类和总结

2014-12-22 07:28 by 李涛的技术博客, 144 阅读, 0 推荐, 收藏, 编辑
摘要:一、DP问题:1、字符串编辑距离。http://www.cnblogs.com/litao-tech/p/4121878.html2、字符串的组合个数。http://www.cnblogs.com/litao-tech/p/4160368.html3、求一维数组中不重叠的两个子数组的最大和。http... 阅读全文

The Painter's Partition Problem Part I

2014-12-20 14:22 by 李涛的技术博客, 824 阅读, 1 推荐, 收藏, 编辑
摘要:(http://leetcode.com/2011/04/the-painters-partition-problem.html)You have to paint N boards of lenght {A0, A1, A2 ... AN-1}. There are K painters avai... 阅读全文

Construct Binary Tree From Inorder and Preorder/Postorder Traversal

2014-12-20 11:18 by 李涛的技术博客, 157 阅读, 0 推荐, 收藏, 编辑
摘要:map mapIndex;void mapToIndex(int inorder[], int n){ for (int i = 0; i ::value_type(inorder[i], i); }}Node* buildInorderPreorder(int in[], int pr... 阅读全文

Determine If Two Rectangles Overlap

2014-12-17 23:03 by 李涛的技术博客, 139 阅读, 0 推荐, 收藏, 编辑
摘要:判断相交的情况比较复杂,所以从判断不相交的角度考虑。! (P1.y P4.x || P2.y > P3.y || P2.x < P3.x) 阅读全文

Longest Substring Without Repeating Characters

2014-12-17 21:42 by 李涛的技术博客, 108 阅读, 0 推荐, 收藏, 编辑
摘要:int longestSubString(char* arr, int len){ if (arr == NULL || len <= 0) return 0; int i = 0, j = 0; int maxLen = 0; bool exist[256] ... 阅读全文

Lowest Common Ancestor of a Binary Tree

2014-12-17 00:00 by 李涛的技术博客, 112 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree, find the lowest common ancestor of two given nodes in the tree.Node* LCA(Node* root, Node* p, Node* q){ if (root == NULL || p ... 阅读全文

Lowest Common Ancestor of a Binary Tree, with Parent Pointer

2014-12-16 23:51 by 李涛的技术博客, 227 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree, find the lowest common ancestor of two given nodes in tree. Each node contains a parent pointer which links to its parent.int get... 阅读全文

Lowest Common Ancestor of a Binary Search Tree (BST)

2014-12-16 23:39 by 李涛的技术博客, 151 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary search tree(BST), find the lowest common ancestor of two given nodes in the BST.Node* LCA(Node* root, Node* p, Node* q){ if (!root |... 阅读全文