theoretical basis
The essence of greed is to select the local optimum at each stage, so as to achieve the global optimum.
To be honest, the greedy algorithm does not have a fixed routine.
455. Distributing cookies
# Let's say you're a great parent and want to give your kids some cookies. However, each child is given no more than o ...

Posted by yhingsmile on Wed, 21 Dec 2022 17:11:06 +0300

How to understand fuzzy clustering
The boundaries between things, some are clear, others are blurred. When clustering involves fuzzy boundaries between things, fuzzy cluster analysis methods need to be used. How to understand the "fuzziness" of fuzzy clustering: Assume that there are two sets A and B, and one member a. The traditiona ...

This code is mainly about modulus switching. Simply put, the function is to reduce the noise of the ciphertext. This should be in the BGV scheme, but the official example is BFV. There is no such process in BFV. It embeds the modulo switching into the multiplication operation. At the end of the code, it is said that BFV does not need to set the ...

Posted by coalgames on Thu, 01 Dec 2022 20:18:14 +0300

binary search tree
What is a Binary Search Tree?
A binary search tree is first a binary tree. This binary tree has such a feature that all nodes in the left subtree are smaller than the root node, and all nodes in the right subtree are larger than the root node. And the left and right subtrees also satisfy this condition A binary se ...

Posted by Invincible on Thu, 01 Dec 2022 19:52:09 +0300

Save rp before the NOIP exam.
Graph theory is a branch of mathematics, and graphs are the main research object of graph theory. A graph is a graph composed of a number of given vertices and edges connecting two vertices. This graph is usually used to describe a specific relationship between certain things. Vertices are used to represent things, ...

Posted by kaimason1 on Fri, 25 Nov 2022 06:07:16 +0300

Postorder + inorder sequence to construct binary tree
Input sample:
The length of the input sequence in the first line is n, the input of n characters in the second line indicates the sequence of binary tree post-order traversal, and the input of n characters in the third line indicates the sequence of binary tree in-order traversal
9
GHDBEI ...

Posted by Topsy Turvey on Sun, 20 Nov 2022 02:17:57 +0300

232. Implement a queue with a stack
topic:
Please use only two stacks to implement a first-in-first-out queue. The queue should support all operations supported by general queues (push, pop, peek, empty):
Implement the MyQueue class:
void push(int x) pushes element x to the end of the queueint pop() removes and returns an element from t ...

Posted by planethax on Wed, 16 Nov 2022 02:28:04 +0300

Day13. Sliding window maximum value, top K high frequency elements
0239. Sliding window maximum
Link: 0239. Sliding window maximum
Monotonic queue: The queue is monotonic. In order to maintain this monotonicity, when adding elements to the tail of the queue, if the previous element and the current element do not satisfy the monotonic relatio ...

Posted by papacostas on Thu, 10 Nov 2022 19:11:56 +0300

gives you an array of distinct integers, where locations[i] represents the location of the ith city. At the same time, it gives you start, finish and fuel, which respectively represent the departure city, destination city and the total amount of gasoline you have initially.
In each step, if you are in city i , you can choose any city j such th ...

Posted by neonorange79 on Thu, 10 Nov 2022 01:19:00 +0300

14 Day Reading Challenge
MEX vs MED
It can be found that only when the median in the series is equal toWhen the condition is met, that is, the numbers before the median must also be in the sequence, then we can enumerate from 0~n-1, and use l and r to indicate the occurrence of the first i number According to the above formula, it can be se ...

Posted by tryingtolearn on Thu, 20 Oct 2022 18:28:00 +0300