Sequential implementation of queues
typedef struct{
int data[MaxSize];
int front,rear;
} SqQueue;
For the initialization of the sequence queue, front points to the queue head element, and rear points to the next position of the queue tail element, that is, the next position that should be inserted.
void Init(SqQueue q){
q.front=0 ...
Posted by natbrazil on Fri, 01 Jul 2022 21:46:43 +0300
introduction
>_< Now we need to arrange a timetable for the students (the learning order of the course)
But it's not that simple:
curriculum
Precursor course
Course 0
Course 1
Course 0, course 4
Course 2
Course 3
Course 0
Course 4
Course 5
Course 3
Course 6
Course 3
Might as well draw a Graph and try i ...
Posted by noimad1 on Wed, 25 May 2022 22:41:14 +0300
Heap and heap sorting
Definition of heap
The heap is a complete binary tree: except for the last layer, the other layers must be full at several points, and the nodes of the last layer must be filled gradually from left to right
The value of each parent node in the heap must be greater than or equal to (or less than or equal to) the value of ...
Posted by activeradio on Wed, 25 May 2022 13:10:30 +0300
Graph coloring problem
[1]
Given undirected connected graphs, G and m have different colors. These colors are used to color the vertices of graph G, and each vertex has a color. Is there a shading method that makes the 2 vertices of each edge in G have different colors.
[2]
If a graph needs at least m colors to make the two vertices connected b ...
Posted by peeps on Wed, 25 May 2022 11:38:54 +0300
Adapter (adapter mode)
In real life, there are often instances where two objects cannot work together due to incompatible interfaces. At this time, a third party needs to adapt. For example, a Chinese speaker needs an interpreter when talking to an English speaker, a power adapter when using a DC laptop to connect to an AC power supply, a card ...
Posted by Locust on Wed, 25 May 2022 09:43:53 +0300
HDU6831 : Fragrant numbers
[difficulty]
3.5/103.5/103.5/10
In fact, the very simple interval dp
But I didn't have time to think about it at that time//
[title]
Let SSS be an infinite string "1145141919" spliced together to become "114514191911451419114514191919..." "11451419114514191145141919 \ cdots" "1145141 ...
Leaf
Leaf is a distributed ID generation service launched by meituan. Its name is taken from the words of German philosopher and mathematician Leibniz: "there are no two identity leaves in the world." ("there are no two same leaves in the world"), taking a name has such moral meaning, meituan programmer Niu break!
Advantag ...
Posted by Chris_Evans on Wed, 25 May 2022 07:06:18 +0300
Establishment and traversal of binary tree (1) Establishment of binary tree Establish a binary tree by traversing in the first order and in the second order: In the pre order traversal sequence of binary tree, the first element is always the value of the root node of the tree. In the middle order traversal sequence, the value of the node of the ...
Posted by Brandon_R on Wed, 25 May 2022 06:18:05 +0300
strrev
The easiest solution!
s.reverse();
Of course, you can write it yourself!
let len = s.len();
let mut t: char;
for i in 0..len / 2 {
t = s[i];
s[i] = s[len - i - 1];
s[len - i - 1] = t;
}
Integer inversion, if leet writes STD before I32 e.g. std::i32::MAX, official recommendation direct I32
if x > i32::MAX - 1 || x < i ...
Posted by FoTo50 on Wed, 25 May 2022 04:51:23 +0300