Yosgi
Yosgi
Avatar
😀
49 results for LeetCode
  • Time: 30 minutes The idea is to first use the time complexity of On to count, and then solve it using the minimum heap method class Heap { constructor(list, compare = (a, b) => a - b) { this.left = …
    Algorithms Created Thu, 08 Apr 2021 00:00:00 +1200
  • Time: 10 minutes const swap = function (arr,i,j) { [arr[i],arr[j]] = [arr[j],arr[i]] } class MaxHeap { constructor() { this.count = 0 this.data = new Array(this.count + 1) } shiftUp(k) { // Put the …
    Algorithms Created Thu, 08 Apr 2021 00:00:00 +1200
  • Time: Read the answer Since it is a pile exercise, it must be closer to the idea of pile Since we only want the median, there is no need to sort all the numbers. You can use two heaps, a maximum heap …
    Algorithms Created Wed, 24 Mar 2021 00:00:00 +1300
  • Time: Refer to the answer After reading the title, the first thing that comes to mind is that dp cannot escape But writing the conversion equation requires some skill Observe that dp[1][1] = …
    Algorithms Created Mon, 22 Mar 2021 00:00:00 +1300
  • Time: 10 minutes A simple question shouldn’t ask me to write the maximum heap by hand. const swap = function (arr,i,j) { [arr[i],arr[j]] = [arr[j],arr[i]] } class MaxHeap { constructor() { this.count …
    Algorithms Created Sun, 21 Mar 2021 00:00:00 +1300
  • Time: 60 minutes I was misled by the depth of the question and thought that the calculation depth should be done from top to bottom. In fact, it can be done from bottom to top. If the left and right …
    Algorithms Created Sun, 21 Mar 2021 00:00:00 +1300
  • Time: 10 minutes Solve by using the property of pre-order traversal of binary tree var minDiffInBST = function(root) { var min = Infinity var pre = null var dfs = function (root) { if (!root) return …
    Algorithms Created Thu, 18 Mar 2021 00:00:00 +1300
  • Time: 10 minutes The preorder is calculated from top to bottom, there is nothing much to say Converting binary to decimal is quite difficult, so I just parseInt(path, 2) var sumRootToLeaf = …
    Algorithms Created Wed, 17 Mar 2021 00:00:00 +1300
  • Post-order traversal approach to delete target-valued leaf nodes using a dummy root.
    Algorithms Created Wed, 17 Mar 2021 00:00:00 +1300
  • Notes on counting good nodes in a binary tree using DFS with a running max.
    Algorithms Created Wed, 17 Mar 2021 00:00:00 +1300