摘要:
题目:(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... 阅读全文
摘要:
题目: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... 阅读全文
摘要:
题目:(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... 阅读全文
摘要:
题目:(DP, Backtracing)Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Ret... 阅读全文
摘要:
BFS有固定的套路 类似下面这个形式ArrayList queue = new ArrayList();queue.add(root);while(!queue.isEmpty()){ String temp = queue.poll(); for(neigbor : t... 阅读全文
摘要:
题目:Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter can be chan... 阅读全文
摘要:
几个套路第一 fast slow 找中点,找位数。第二 reverse{ ListNode last = prev.next; ListNode curr = last.next; while(curr!=null) { last.next = curr.next; ... 阅读全文
摘要:
题目:(Tree ,Stack)Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3... 阅读全文
摘要:
题目:(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 ... 阅读全文
摘要:
题目:(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... 阅读全文