Yosgi is a software engineer in Auckland with 9+ years of experience across product engineering, frontend architecture, full-stack systems, digital twins, and AI platform work.
The first thing that comes to mind is to find the distance r of all heaters that are the shortest distance from the house, and then return the largest r var findRadius = function(houses, heaters) { …
Time: 60 minutes The quickest way of thinking when getting the question is to enumerate all the speeds at which bananas can be eaten and find the minimum speed at which all bananas can be eaten. The …
Time: 15 minutes There is nothing much to say about conventional heap sort class Heap { constructor(list, compare = (a, b) => a - b) { this.left = index => 2 * index + 1 this.right = index => 2 * …
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 = …
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 …
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] = …
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 …
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 …
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 …