摘要: 1 """ 2 本题简单的一点就在于摆放的顺序和原顺序一致 3 定义dp[i]为前i本书能够到达的最小高度。 4 则对于第i+1本书,有两类选择。 5 如自己单独一层,则状态转移方程为dp[i+1] = dp[i] + h[i+1] 6 如果和前面的书放在一起,则状态转移方程为 7 dp[i+1] 阅读全文
posted @ 2020-03-04 22:59 yawenw 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? 3 Example: 4 Input: 3 5 Output: 5 6 Explanation: 阅读全文
posted @ 2020-03-04 22:05 yawenw 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given a binary tree, find its minimum depth. 3 The minimum depth is the number of nodes along the shortest path from the root node down to the 阅读全文
posted @ 2020-03-04 17:41 yawenw 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given an unsorted array of integers, find the length of the longest consecutive elements sequence. 3 Your algorithm should run in O(n) complex 阅读全文
posted @ 2020-03-04 16:52 yawenw 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given a list of non negative integers, arrange them such that they form the largest number. 3 Example 1: 4 Input: [10,2] 5 Output: "210" 6 Exa 阅读全文
posted @ 2020-03-04 16:20 yawenw 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given a string s, partition s such that every substring of the partition is a palindrome. 3 Return all possible palindrome partitioning of s. 阅读全文
posted @ 2020-03-04 15:54 yawenw 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Two elements of a binary search tree (BST) are swapped by mistake. 3 Recover the tree without changing its structure. 4 Example 1: 5 Input: [1 阅读全文
posted @ 2020-03-04 12:38 yawenw 阅读(154) 评论(0) 推荐(0) 编辑