摘要:
何谓动态规划? 以菲波那切数列为例, 该递归调用中,有大量重复子集,如图 在计算fib(5) 的时候,多次计算了fib(2)的值。那为何不在递归搜索的基础上,添加一个小笔记本进行记忆化:只在第一次fib(2)的时候计算结果,而下次再call fib(2)的时候, 可以直接O(1)时间从记事本拿到该结
阅读全文
posted @ 2018-05-22 07:13
程序媛詹妮弗
阅读(641)
推荐(0)
编辑
摘要:
A message containing letters from A-Z is being encoded to numbers using the following mapping: Given a non-empty string containing only digits, determ
阅读全文
posted @ 2018-05-22 06:33
程序媛詹妮弗
阅读(160)
推荐(0)
编辑
摘要:
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen
阅读全文
posted @ 2018-05-22 04:58
程序媛詹妮弗
阅读(216)
推荐(0)
编辑
摘要:
Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node.
阅读全文
posted @ 2018-05-22 03:15
程序媛詹妮弗
阅读(92)
推荐(0)
编辑
摘要:
Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or
阅读全文
posted @ 2018-05-22 03:01
程序媛詹妮弗
阅读(176)
推荐(0)
编辑
摘要:
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Input: S = "ADOB
阅读全文
posted @ 2018-05-22 02:15
程序媛詹妮弗
阅读(219)
推荐(0)
编辑