摘要: 题目:(DP)Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from t... 阅读全文
posted @ 2015-01-02 10:13 fengmang 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representat... 阅读全文
posted @ 2015-01-02 04:06 fengmang 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 题目:(DP)Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST... 阅读全文
posted @ 2015-01-02 03:43 fengmang 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 题目:(DP, Backtracing)Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Ret... 阅读全文
posted @ 2015-01-02 01:53 fengmang 阅读(255) 评论(0) 推荐(0) 编辑
摘要: BFS有固定的套路 类似下面这个形式ArrayList queue = new ArrayList();queue.add(root);while(!queue.isEmpty()){ String temp = queue.poll(); for(neigbor : t... 阅读全文
posted @ 2015-01-01 11:07 fengmang 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 题目:Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter can be chan... 阅读全文
posted @ 2015-01-01 10:44 fengmang 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 几个套路第一 fast slow 找中点,找位数。第二 reverse{ ListNode last = prev.next; ListNode curr = last.next; while(curr!=null) { last.next = curr.next; ... 阅读全文
posted @ 2015-01-01 07:02 fengmang 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 题目:(Tree ,Stack)Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3... 阅读全文
posted @ 2015-01-01 06:51 fengmang 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 题目:(Stack)Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in ... 阅读全文
posted @ 2015-01-01 04:39 fengmang 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 题目:(LinkedList)Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3... 阅读全文
posted @ 2015-01-01 01:01 fengmang 阅读(79) 评论(0) 推荐(0) 编辑