03 2020 档案
摘要:package LeetCode_338 /** * 338. Counting Bits * https://leetcode.com/problems/counting-bits/description/ * https://www.cnblogs.com/grandyang/p/5294255
阅读全文
摘要:package LeetCode_1064 /** * 1064. Fixed Point * Lock by LeetCode * Given an array A of distinct integers sorted in ascending order, return the smalles
阅读全文
摘要:package LeetCode_622 /** * 622. Design Circular Queue * https://leetcode.com/problems/design-circular-queue/description/ * * Your implementation shoul
阅读全文
摘要:package LeetCode_71 import java.util.* /** * 71. Simplify Path * https://leetcode.com/problems/simplify-path/description/ * * Example 5: Input: "/a/..
阅读全文
摘要:package LeetCode_347 import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap /** * 347. Top K Frequent Elements * htt
阅读全文
摘要:package LeetCode_7 /** * 7. Reverse Integer * https://leetcode.com/problems/reverse-integer/description/ * */ class Solution { fun reverse(x_: Int): I
阅读全文
摘要:/** 26. Remove Duplicates from Sorted Array https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/ */ class Solution { fun rem
阅读全文
摘要:package _Sort.Algorithm /** * https://www.geeksforgeeks.org/merge-sort/ * https://www.cnblogs.com/chengxiao/p/6194356.html * best/worst/average Time c
阅读全文
摘要:/** * 55. Jump Game * https://leetcode.com/problems/jump-game/description/ * */ class Solution { fun canJump(nums: IntArray): Boolean { //method 1 /*v
阅读全文
摘要:/** * 860. Lemonade Change * https://leetcode.com/problems/lemonade-change/description/ * */ class Solution { //使用贪心,策略是每次找钱选择大面额,尽量保留5元的 fun lemonade
阅读全文
摘要:什么是贪心算法? 在对问题求解时,总是做出对当前来看是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的仅是在某种意义上的局部最优解、从而求得整体最优解。 贪心算法不有固定的算法框架,算法设计的关键是贪心策略的选择。但贪心算法并不是对所有问题都能得到最优解,选择贪心策略要具备无后效性,即某个状
阅读全文
摘要:/** * 426. Convert Binary Search Tree to Sorted Doubly Linked List * https://www.lintcode.com/problem/convert-binary-search-tree-to-sorted-doubly-link
阅读全文
摘要:package LeetCode_316 import java.lang.StringBuilder /** * 316. Remove Duplicate Letters * https://leetcode.com/problems/remove-duplicate-letters/descr
阅读全文
摘要:什么是Segment Tree? 它是一个binary tree,表示每个parent只有两个children;他是平衡的(balanced binary tree),但不定是完美平衡,保证是O(logn)的高度。 它的每个叶子结点代表了数组里的每一个元素,并且还带有一个范围:start,end,如
阅读全文
摘要:package LeetCode_47 /** * 47. Permutations II * https://leetcode.com/problems/permutations-ii/description/ * * Given a collection of numbers that migh
阅读全文
摘要:/** * 46. Permutations * https://leetcode.com/problems/permutations/description/ * Given a collection of distinct integers, return all possible permut
阅读全文
摘要:package LeetCode_1382 import kotlin.collections.ArrayList /** * 1382. Balance a Binary Search Tree * https://leetcode.com/problems/balance-a-binary-se
阅读全文
摘要:/** * 303. Range Sum Query - Immutable * https://leetcode.com/problems/range-sum-query-immutable/description/ * * Given an integer array nums, find th
阅读全文
摘要:Binary Indexed Tree的作用 Binary Indexed Tree(BIT)现多用于高效计算数列的前序和,区间和。它可以在O(logn)的时间得到任意的前序和(prefix sum)。如一个array[2,5,-1,3,6],要计算第2个元素到第4个元素的和:5+-1+3=7。 B
阅读全文
摘要:package LeetCode_1356 import java.util.* /** * 1356. Sort Integers by The Number of 1 Bits * https://leetcode.com/problems/sort-integers-by-the-number
阅读全文
摘要:package LeetCode_190 /** * 190. Reverse Bits * https://leetcode.com/problems/reverse-bits/description/ * Reverse bits of a given 32 bits unsigned inte
阅读全文
摘要:/** * 3. Longest Substring Without Repeating Characters * https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ *
阅读全文
摘要:/** * 989. Add to Array-Form of Integer * https://leetcode.com/problems/add-to-array-form-of-integer/description/ * For a non-negative integer X, the
阅读全文
摘要:/** * 896. Monotonic Array * https://leetcode.com/problems/monotonic-array/description/ * */ class Solution { fun isMonotonic(A: IntArray): Boolean {
阅读全文
摘要:package LeetCode_253 import LeetCode_252.Interval import java.util.Arrays /** * 253. Meeting Rooms II * (Lock by Leetcode) * https://www.lintcode.com/
阅读全文
摘要:/** * 461. Hamming Distance * https://leetcode.com/problems/hamming-distance/description/ * The Hamming distance between two integers is the number of
阅读全文