上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 20 下一页
摘要: 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) 编辑
摘要: 1 """ 2 Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node's value equals the given val 阅读全文
posted @ 2020-03-03 23:02 yawenw 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. 3 Note: 4 You may assume k is always valid, 1 阅读全文
posted @ 2020-03-03 22:49 yawenw 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. 3 You may assum 阅读全文
posted @ 2020-03-02 22:54 yawenw 阅读(79) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 20 下一页