上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 80 下一页
摘要: 什么是贪心算法? 在对问题求解时,总是做出对当前来看是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的仅是在某种意义上的局部最优解、从而求得整体最优解。 贪心算法不有固定的算法框架,算法设计的关键是贪心策略的选择。但贪心算法并不是对所有问题都能得到最优解,选择贪心策略要具备无后效性,即某个状 阅读全文
posted @ 2020-03-24 14:53 johnny_zhao 阅读(390) 评论(0) 推荐(0)
摘要: /** * 426. Convert Binary Search Tree to Sorted Doubly Linked List * https://www.lintcode.com/problem/convert-binary-search-tree-to-sorted-doubly-link 阅读全文
posted @ 2020-03-24 14:47 johnny_zhao 阅读(97) 评论(0) 推荐(0)
摘要: package LeetCode_316 import java.lang.StringBuilder /** * 316. Remove Duplicate Letters * https://leetcode.com/problems/remove-duplicate-letters/descr 阅读全文
posted @ 2020-03-23 12:16 johnny_zhao 阅读(129) 评论(0) 推荐(0)
摘要: 什么是Segment Tree? 它是一个binary tree,表示每个parent只有两个children;他是平衡的(balanced binary tree),但不定是完美平衡,保证是O(logn)的高度。 它的每个叶子结点代表了数组里的每一个元素,并且还带有一个范围:start,end,如 阅读全文
posted @ 2020-03-22 11:09 johnny_zhao 阅读(182) 评论(0) 推荐(0)
摘要: package LeetCode_47 /** * 47. Permutations II * https://leetcode.com/problems/permutations-ii/description/ * * Given a collection of numbers that migh 阅读全文
posted @ 2020-03-20 14:44 johnny_zhao 阅读(98) 评论(0) 推荐(0)
摘要: 传送门 阅读全文
posted @ 2020-03-20 13:54 johnny_zhao 阅读(3206) 评论(0) 推荐(0)
摘要: /** * 46. Permutations * https://leetcode.com/problems/permutations/description/ * Given a collection of distinct integers, return all possible permut 阅读全文
posted @ 2020-03-16 20:03 johnny_zhao 阅读(109) 评论(0) 推荐(0)
摘要: package LeetCode_1382 import kotlin.collections.ArrayList /** * 1382. Balance a Binary Search Tree * https://leetcode.com/problems/balance-a-binary-se 阅读全文
posted @ 2020-03-16 13:46 johnny_zhao 阅读(218) 评论(0) 推荐(0)
摘要: /** * 303. Range Sum Query - Immutable * https://leetcode.com/problems/range-sum-query-immutable/description/ * * Given an integer array nums, find th 阅读全文
posted @ 2020-03-11 10:55 johnny_zhao 阅读(100) 评论(0) 推荐(0)
摘要: Binary Indexed Tree的作用 Binary Indexed Tree(BIT)现多用于高效计算数列的前序和,区间和。它可以在O(logn)的时间得到任意的前序和(prefix sum)。如一个array[2,5,-1,3,6],要计算第2个元素到第4个元素的和:5+-1+3=7。 B 阅读全文
posted @ 2020-03-10 00:24 johnny_zhao 阅读(236) 评论(0) 推荐(0)
上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 80 下一页