Enumeration, simulation and sorting
Example: consecutive interval number
Xiao Ming has been thinking about such a strange and interesting question these days:
How many consecutive intervals are there in an arrangement of 1 ∼ N?
The definition of the serial interval here is:
If all the elements in the interval [L,R] (i.e. the L-th to r-th elements of this arrangement) can ...
Posted by trrobnett on Sun, 20 Feb 2022 07:25:50 +0100
[Luogu] P1608 path statistics
Title address:
https://www.luogu.com.cn/problem/P1608
Title Description: The staff quality of "RP restaurant" is not general. After calculating the same phone number, they are ready to let HZH and TZY deliver fast food. They draw a map of the city they live in. It is known that on their map, there are
...
Posted by gio2k on Sun, 20 Feb 2022 05:44:27 +0100
[recent force buckle] word split + merge interval + linked list sorting + adjust the array order so that the odd number precedes the even number
Word splitting (medium)
dynamic programming
”Whether leetcode "can be composed and decomposed into - whether" l "is stored in the dictionary and subsequent substrings can be composed when the step size is 1, etc; When the step size is 2, "le" is stored in the dictionary and subsequent substrings can be compose ...
Posted by shorty114 on Sun, 20 Feb 2022 04:15:26 +0100
On tree chain subdivision
Tree chain subdivision
Template question
As the name suggests, it is to express the shape of the tree with a linear linked list. Then the first thing is to build a tree.
ll siz[N],dep[N],son[N],fa[N];//Son is the coordinate of the great son whose ancestor is x
void build_tree(int now)
{
siz[now]=1;//Size of initialization tree
for(int i=h ...
Posted by sonic_2k_uk on Sat, 19 Feb 2022 22:39:54 +0100
Longest ascending subsequence model for dynamic programming
preface
Let's first analyze the original LIS problem with Yan dp analysis
Strange thief Kidd's glider wing
Title Transfer door
We can start at any point, and there are two directions: left and right. We have to make the most of the buildings we pass
Solution idea: let's take a look at the board problem of the longest body sequence whe ...
Posted by j007w on Sat, 19 Feb 2022 21:45:40 +0100
Depth first search of graph algorithm series
Hematemesis sorting programmer must read list: https://github.com/silently9527/ProgrammerBooks
WeChat official account: beta Java
In the first part, we learned depth first search and knew how to find the path in the graph through depth first search; In this article, we continue to learn other application scenarios of depth first search alg ...
Posted by sailu_mvn on Sat, 19 Feb 2022 19:35:42 +0100
How to use JS to sort various arrays?
JS implementation of various sorting
There are many kinds of sorting in data structure algorithms, common and uncommon, including at least ten kinds. According to their characteristics, they can be roughly divided into two types: comparison sort and non comparison sort.
Comparison sort: the relative order between elements is determined by com ...
Posted by Mordecai on Sat, 19 Feb 2022 19:07:45 +0100
Hey, dare you come to a class!
The so-called people gather in groups and things divide in groups. People like to be with people who have the same personality and hobbies.
Commonly known as: get along! Pretty boy, I like you very much~
A and B were childhood sweethearts. A met C through B and found that their interests and hobbies were surprisingly consistent. The three g ...
Posted by eRott on Sat, 19 Feb 2022 18:09:16 +0100
Data processing algorithm_ 2015 dataset
background
Download address: https://rrc.cvc.uab.es/?ch=4&com=downloads
Note: this data is open source data, but you need to register an account. You can download it simply by registering;
Introduction: it is used for text detection task. The data includes 1000 training samples and 500 test samples;
Required data display
Firstly, the d ...
Posted by basdog22 on Sat, 19 Feb 2022 16:57:28 +0100
leetcode-236. Nearest common ancestor of binary tree
leetcode-236. Nearest common ancestor of binary tree
deque method
class Solution {
public:
deque<TreeNode*> dqp;
deque<TreeNode*> dqq;
bool findNode(TreeNode* root, deque<TreeNode*>& dq, TreeNode* target) {
dq.push_back(root);
if(root == target) {
return true;
}
bool ret = false;
if(root->left) ...
Posted by BLINDGUY on Sat, 19 Feb 2022 13:48:41 +0100