The kth largest element in the array
Topic introduction
Question 215: https://leetcode-cn.com/problems/kth-largest-element-in-an-array/
The kth largest element was found in an unordered array. Note that you need to find the k-th element of the array instead of the largest element.
analysis
To find the k-largest element in the array, the first thing you can think of is, of cou ...
Posted by McManCSU on Fri, 11 Feb 2022 03:38:52 +0100
Algorithm - heap sort
Large top heap: Based on the complete binary tree, the value of each node is greater than or equal to the value of its left and right child nodes
p moves forward through the loop p -- pointer in the main function
public static void main(String[] args) {
int[] arr = {8,7,3,5,4,9,1,3};
for (int p = arr.length-1;p>=0;p--){
...
Posted by witham on Fri, 11 Feb 2022 00:35:33 +0100
Turing Tree (offline query + segment tree / tree array or chairman tree)
Title Link: Turing Tree
General meaning
There is a sequence of length n, numbered from 1 to n, and each position has an element value
Query: multiple queries, the sum of elements after de duplication in each query [l, r]
Problem solving ideas
Offline query + segment tree / tree array or chairman tree
Acacia topic recommendation
Solution ...
Posted by Zippyaus on Fri, 11 Feb 2022 00:17:29 +0100
Sparse arrays and queues
3.1 sparse array
3.1.1 first look at a demand
The Gobang program has the functions of saving, exiting and continuing the upper board. Analyze the problem: Because many values of two-dimensional array are the default value of 0, many meaningless data = = > sparse array are recorded.
3.1.2 basic introduction
When most elements in an array ...
Posted by liquidmind on Thu, 10 Feb 2022 23:03:41 +0100
Algorithm analysis and design of Beihang 2020-C2
Say at the beginning
This blog only provides learning materials and my personal review. In the process of learning algorithms, the code should be typed by myself. It is not convenient to copy and paste the code directly. Copy code without harm.
preface
The original intention of writing this series of blogs is that the process of learning alg ...
Posted by plaggypig on Thu, 10 Feb 2022 22:33:22 +0100
[Simulation Competition] infection (point division, strong connected component reduction point)
background
One day, a group of dogs suddenly began to moisten people in the past, so the students banned this part of the science and technology building.
~
Deadcodes: old machine room
Problem surface
Your country
...
Posted by Janjan on Thu, 10 Feb 2022 21:07:32 +0100
Notes on sword finger offer JZ1-5
A references
Book "sword finger offer (Second Edition)"
Search in JZ01 binary array
1. Title Description
In a two-dimensional array (each one-dimensional array has the same length), each row is sorted in ascending order from left to right, and each column is sorted in ascending order from top to bottom. Please complete a function, ...
Posted by sentback on Thu, 10 Feb 2022 18:21:25 +0100
acwing game 24
acwing game 24
This week's competition has three topics: simulation, enumeration and simulation
acwing 4070. XOR
Link: 4070. XOR - AcWing question bank
Title Description
Problem solving ideas
Very simple simulation, record the maximum value and the last input when entering, and don't even open the array
code
#include<iostream>
...
Posted by gonsman on Thu, 10 Feb 2022 16:50:50 +0100
01. Introduction to time complexity, bubble algorithm diagram and java program
Understanding time complexity:
Constant time operation: if an operation has nothing to do with the amount of data, it is completed within a fixed time every time, which is called constant operation.
Time complexity is an indicator of the number of constant operations in an algorithm flow. It is often represented by 0 (pronounced big0). S ...
Posted by timmy0320 on Thu, 10 Feb 2022 14:39:01 +0100
2022 Niuke winter vacation algorithm basic training camp 4 "ABCDEFGHIJK"
2022 Niuke winter vacation algorithm basic training camp 4
A-R
Title Description:
Xiao Hong gets a string of length n, which is only composed of uppercase letters.
Xiao Hong likes red very much (indicated by the letter 'R'), but she hates purple very much (indicated by the letter 'P'). She wants to take a continuous substring that conta ...
Posted by nobodyk on Thu, 10 Feb 2022 12:34:19 +0100