Summary of classic binary tree problems
1. Preorder traversal of binary tree
Force buckle OJ link
Give you the root node of the binary tree, root, and return the preorder traversal of its node value.
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { t ...
Added by latvaustin on Wed, 05 Jan 2022 04:06:28 +0200
Codeforces Good Bye 2021: 2022 is NEAR ABCDE
A. Integer Diversity
Count the number of figures with different absolute values in all figures. Only when the number of absolute values is less than 2
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=200100;
int n,m,t;
int w[N];
int cw[N];
int main(){
cin>>t;
while(t--) ...
Added by jibosh on Wed, 05 Jan 2022 03:22:05 +0200
Computer experiment of data structure (Chapter 2) II
Bibliography: data structure course (Fifth Edition), edited by Li Chunbao Computer experiment of data structure (Chapter II) I
Time complexity:
Find elements with sequence number i(1 ≤ i ≤ n)Find the first element with a value of xInsert a new element as the first elementInsert the new element as the last elementInsert the i(2 ≤ i &l ...
Added by wee493 on Wed, 05 Jan 2022 01:13:18 +0200
Data structure - stack
Learn about today's record stack
Stack
Stack (stack) A stack is an ordered list of Filo first in last out. Stack is a special linear table that restricts the insertion and deletion of elements in a linear table to the same end of the linear table. The end that allows insertion and deletion is the changing end, which is called the top of t ...
Added by ferpadro on Tue, 04 Jan 2022 23:47:47 +0200
Collection of JAVA source code learning - Hashtable
Class description
public class Hashtable<K,V>
extends Dictionary<K,V>
implements Map<K,V>, Cloneable, Serializable
This class implements a hash table that maps keys to values. Any non empty object can be used as a key or value.
To successfully store and retrieve objects from the hash table, the objects used as keys must imp ...
Added by jeffz2008 on Tue, 04 Jan 2022 23:19:46 +0200
Data structure and algorithm -- 10 Sort (bubble, select, insert, hill, quick, merge, cardinality)
1. Bubble sorting
The basic idea of Bubble Sorting is to compare the values of adjacent elements from front to back (starting from the elements with smaller subscripts) through the sequence to be sorted, and exchange if the reverse order is found, so that the elements with larger values gradually move from front to back, just like bubbles unde ...
Added by hellangel on Tue, 04 Jan 2022 21:00:19 +0200
[summary of Li Kou brushing questions] (dictionary tree)
Dictionary tree
Concept of dictionary tree
This section is mainly for reference Reference link
Dictionary tree is also called Trie tree and prefix tree. As the name suggests, it is a data structure that maintains strings.
Dictionary tree, as the name suggests, is a tree about "dictionary". That is, it is a storage method for ...
Added by Txtlocal on Tue, 04 Jan 2022 19:51:41 +0200
[data structure and algorithm] in-depth analysis of the solution idea and algorithm example of "spiral matrix"
1, Title Requirements
Give you a matrix with m rows and n columns. Please return all the elements in the matrix in a clockwise spiral order.Example 1:
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
Output:[1,2,3,6,9,8,7,4,5]
Example 2:
Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
Output:[1,2,3,4,8,12,11,10,9,5,6,7]
Tips:
m == mat ...
Added by thegreatdanton on Tue, 04 Jan 2022 14:14:34 +0200
[small Y learning algorithm] ⚡ Daily LeetCode punch in ⚡ ️——3. Longest substring without duplicate characters
📢 preface
🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌻🌲 Punching out an algorithm problem every day is not only a learning process, but also a sharing process 😜🌲 Tip: the problem-solving programming languages in this column are C# and Java🌲 To maintain a state of learning every day, let's wo ...
Added by thines on Tue, 04 Jan 2022 11:55:47 +0200
[sword finger offer] second layer
Stack push and stack sequence
Title Description:
Review the basic structure of the stack:
The stack structure is first in first out, last in first out Stack in sequence: [1,2,3,4,5] stack out sequence [4,5,3,2,1], does it belong to the same stack in and out sequence? There may be hints in the stack:
Idea:
Use a stack simulati ...
Added by remal on Tue, 04 Jan 2022 10:10:15 +0200