Sorting - Minimum k number, median of data stream, heap module, double heap

Sword finger Offer 40. Minimum number of k Just in the last article, we talked about the two sorting methods of small top heap and fast row, which can solve the k-th problem. Official fast platoon use ij exchange Here is my wrong idea To find the k-th, you should first be able to write fast rows. For a round of fast scheduling, the lef ...

Posted by DangerousDave86 on Sat, 09 Oct 2021 21:58:01 -0700

⭐Introduction to Algorithms⭐Heap Medium 02 - LeetCode 703.Largest K element in data flow

1. Title 1. Title Description _Design a class that finds the kth largest element in the data stream. Note that the kth largest element is sorted, not the kth different element. Implement the KthLargest class:_1) KthLargest(int k, int[] nums) initializes objects using integer k and integer stream nums._2) int add(int val) inserts Vals ...

Posted by classic on Sat, 09 Oct 2021 12:21:15 -0700

⭐Introduction to Algorithms⭐Heap 03 - LeetCode 373.Find and Minimum K Pair Number

1. Title 1. Title Description Given two arrays of integers nums1 and nums2 in ascending order, and an integer k k k. Define a pair of values ( u , ...

Posted by shiggins on Sat, 09 Oct 2021 10:02:47 -0700

Minimum refueling times

Title: the car starts from the starting point to the destination, which is located at the target mile east of the starting position. There are gas stations along the way. Each station[i] represents a gas station. It is located at station[i][0] miles east of the starting position, and there are station[i][1] liters of gasoline. Suppose that ...

Posted by jokerofsouls on Sat, 09 Oct 2021 02:42:46 -0700

[mysql] Leetcode question brushing record

181. Employees who exceed the manager's income Employee The table contains all employees, and their managers belong to employees. Every employee has one Id,In addition, there is a list of managers corresponding to employees Id. +----+-------+--------+-----------+ | Id | Name | Salary | ManagerId | +----+-------+--------+-----------+ | 1 | ...

Posted by adige on Fri, 08 Oct 2021 11:03:16 -0700

leetcode brush record day019:384 and 198

384. Medium difficulty: Method 1: Violence: time complexity O(n^2) space complexity O(n) Topic meaning: the topic requires us to implement a constructor and two methods of the Solution class 1. Solution(int[] nums) initializes the object with an integer array nums // Title passed in array nums public Solution(int[] nums) { // Array and n ...

Posted by DJTim666 on Thu, 07 Oct 2021 13:41:41 -0700

The kth largest element in the array of LeetCode

The title requires the k-largest element in the array. My most direct idea is to sort the whole array and then return the k-largest element in the array. 1. Bubble sorting To complete the sorting of the array nums, bubble sorting requires nums.size() - 1 round of sorting, because the last element does not need to be sorted. Bubble sort e ...

Posted by capitala on Thu, 07 Oct 2021 08:33:11 -0700

The way to solve the problem of force deduction ----- traversal of array

Refer to the brushing order: Force deduction brushing sequence This article makes a self summary, summarizes their own ideas when doing problems and the official ideas for solving problems. 485 maximum number of consecutive 1 It's a very simple question, so there's nothing to say. Put a code. class Solution { public int findMaxCons ...

Posted by eskimowned on Wed, 06 Oct 2021 14:21:40 -0700

LeetCode notes: Biweekly Contest 62

LeetCode notes: Biweekly Contest 62 1. Topic 1 1. Problem solving ideas2. Code implementation 2. Topic 2 1. Problem solving ideas2. Code implementation 3. Topic 3 1. Problem solving ideas2. Code implementation 4. Topic 4 1. Problem solving ideas2. Code implementation 1. Topic 1 The test question link given in questi ...

Posted by flashbot on Tue, 05 Oct 2021 17:36:05 -0700

LeetCode-35 search insertion position solution C++

35. Search insertion positionhttps://leetcode-cn.com/problems/search-insert-position/ Simple difficulty 1103 Given a sort array and a target value, find the target value in the array and return its index. If the target value does not exist in the array, returns the position where it will be inserted in order. Please use a time complexity of ...

Posted by newzub on Sun, 03 Oct 2021 17:10:37 -0700