Simple implementation of dictionary tree, prefix tree and Trie tree [insert, search and find prefix]
Simple implementation of dictionary tree, prefix tree and Trie tree [insert, search and find prefix]
1.Trie tree
Trie tree, namely prefix tree, also known as word lookup tree and dictionary tree, is a tree structure and a variant of hash tree. The typical application is to count and sort a large number of strings (but not limited to strings), ...
Posted by Courbois on Fri, 04 Mar 2022 21:07:43 +0100
Python quick sort idea and template to solve the quick sort of the K-th largest element in the Leetcode215 array
Recommend a blog post with a clear idea of quick sorting: https://blog.csdn.net/jiangtianjiao/article/details/88929408 The contents are as follows: basic thought Select a benchmark number and divide the data to be sorted into two independent parts through one-time sorting. All data in one part is smaller than all data in the other part. Then qu ...
Posted by toms100 on Fri, 04 Mar 2022 15:22:52 +0100
Using conditional lock to control the synchronization of multiple threads (java implementation)
catalogue
Title:
answer:
Explanation:
Recently, I did a topic of multithreading synchronization. I used conditional locking to solve it. By doing this problem, we can have a basic understanding of the application of locks. This article will briefly explain it.
Ps: after finishing, I found that this is the original question on Li buckle. T ...
Posted by moonman89 on Fri, 04 Mar 2022 13:34:38 +0100
Implement stack with queue
Title Description: Please use only two queues to implement a last in first out (LIFO) stack, and support all four operations of ordinary queues (push, top, pop and empty).
Implement MyStack class:
void push(int x) pushes element X to the top of the stack. int pop() removes and returns the top of stack element. int top() returns the top elemen ...
Posted by robin on Fri, 04 Mar 2022 04:21:17 +0100
"Sword finger Offer (2nd Edition)" series questions
Sword finger offer brush questions
03 [duplicate number in array]
class Solution {
public:
int findRepeatNumber(vector<int>& nums) {
sort(nums.begin(),nums.end());
for(int i=0;i<nums.size();i++)
{
if(nums[i+1]==nums[i])
{
//cout<<nums[i]<<endl;
...
Posted by Cobby on Thu, 03 Mar 2022 23:19:24 +0100
LeetCode selected TOP interview questions 138 Copy linked list with random pointer
Title Description
Given a linked list of length n, each node contains an additional random pointer random, which can point to any node or empty node in the linked list.Construct a deep copy of this linked list. The deep copy should consist of exactly n new nodes, in which the value of each new node is set to the value of its corresponding orig ...
Posted by rhodesa on Thu, 03 Mar 2022 15:06:28 +0100
Heap topK problem heap sorting priority queue object comparison problem
Heap topK problem - heap sorting
The concept of heap ❓
To represent a binary tree with the child's representation (a common representation for brushing questions) is essentially a chain storage. In fact, there is also a sequential storage for the storage of binary trees. To put it bluntly, take an array to store a binary tree, and the way to ...
Posted by wendymelon on Thu, 03 Mar 2022 12:01:02 +0100
JS: Three Algorithms day1
Backtracking, greedy, and dynamic planning ideas are developed by doing a lot of exercises, not in a few days, and the title won't tell you which algorithm to use. Keep working on the problem.
Back-tracking - 46. Full arrangement (medium) 51. Queen N (difficult)
Pre-order traversal code executes at the point in time before entering a node, an ...
Posted by jkmcgrath on Wed, 02 Mar 2022 18:34:27 +0100
Number of Marked Intervals with Fractions
Source of ideas with score https://blog.csdn.net/qq_51118755/article/details/122680838
With score
Title Description
100 Can be expressed as a fraction: 100 = 3 + 69258 / 714
It can also be expressed as:100 = 82 + 3546 / 197
Attention Feature: Number 1 in score~9 Occurs separately and only once (excluding 0).
Like this with fractio ...
Posted by eneficus on Wed, 02 Mar 2022 18:30:53 +0100
KMP algorithm [note]
1 overview of KMP algorithm
Recently, when writing leetcode28, I thought of KMP algorithm. I have seen this algorithm roughly before and searched a lot of information on the Internet, but I still can't understand it. Recently, I read it in detail again and finally found something. So make a record to facilitate your memory. Problem Description ...
Posted by coreyk67 on Wed, 02 Mar 2022 14:45:55 +0100