Leetcode DFS + backtracking topic (under update)

[product understanding foundation DFS] 695. Maximum area of the island This problem is equivalent to finding the largest sub block size in the connected sub blockYou need to mark whether the grid has been accessedThe essence of using the direction array to cycle four times is the same as directly writing the following code. It depends on ...

Added by DoD on Fri, 15 Oct 2021 02:06:22 +0300

Zab protocol - election algorithm election phase source code analysis

2021SC@SDUSC Introduction to the election stage Before analyzing the source code, let's first understand the election process. This stage is the first stage of Zab. Each node is in the election node at the beginning. As long as a node gets more than half of the votes of the nodes, it can be elected a quasi Leader. Only when it reaches the ...

Added by smonsivaes on Thu, 14 Oct 2021 23:29:48 +0300

Retrospective Topic Solution and Example

Summary from Code casual backtracking What's the use of backtracking? Backtracking = Endless, it is always possible to use backtracking when you need to keep making choices and try all the choices to find a solution. For example: Combination Problem: Find a set of k numbers in N numbers according to certain rulesCutting Problem: There are ...

Added by twister47 on Thu, 14 Oct 2021 22:51:56 +0300

Chapter 3 Dijkstra algorithm of search and graph theory shortest path algorithm

1. Algorithm idea 1. Problems solved Dijkstra algorithm is an algorithm based on greed. Its purpose is to solve the single source shortest path problem of positive weight graph. The so-called positive weight means that the weight of all edges in the graph is positive. The so-called single source shortest path is the shortest path from a start ...

Added by mikeT on Thu, 14 Oct 2021 07:55:50 +0300

js algorithm and data structure -- two-way linked list 2

Get implementation – get the corresponding location element The idea is the same as that of the single linked list! code // 7 get method -- it is not efficient. It can be divided equally. After all, there is a tail node! DoublyLinkedList.prototype.get = function(position){ if(position < 0 || position >= this.length) return ...

Added by trdesigns on Thu, 14 Oct 2021 07:42:09 +0300

1127 sweet butter (spfa solves the shortest path)

1. Problem Description: Farmer John found a way to make the sweetest butter in Wisconsin: sugar. Put the sugar on a pasture and he knew that N cows would come and lick it, so that he could make super sweet butter that could sell well. Of course, he will pay extra for the cows. Farmer John is very cunning, just like Pavlov in the past. He knows ...

Added by brainstorm on Wed, 13 Oct 2021 16:25:43 +0300

[leetcode] hash table - Roman numeral to integer

Title: Roman numerals contain the following seven characters: I, V, X, L, C, D and M. characternumerical valueI1V5X10L50C100D500M1000 For example, the Roman numeral 2 is written as II, which is two parallel ones. 12 is written as XII, which is X + II. 27 is written as XXVII, which is XX + V + II. Usually, the small Roman numerals are to the r ...

Added by sprint10s on Wed, 13 Oct 2021 05:38:31 +0300

Machine learning -- a simple introduction to KNN algorithm

Level 1: manually implement simple kNN algorithm 1 Introduction to KNN algorithm 1.1 algorithm flow of KNN algorithm kNN algorithm is actually the simplest of many machine learning algorithms, because the idea of the algorithm can be summarized in eight words: "he who is near is red, and he who is near is black". Suppose there ...

Added by Phantazm on Wed, 13 Oct 2021 04:09:27 +0300

[Leetcode monotone stack] 84. The largest rectangle in the histogram (dp optimized double pointer calculation with jump saving calculation!! how to think about the problem solution!!)

Leetcode84 1. Problem description 2. Solutions Solution 1: double pointer (O(n^2) timeout) (thinking about a solution to the problem 1. I can understand it by looking at the figure. For each column, the largest rectangle containing this column is the area between the first smaller column on the left and right, and then find the ma ...

Added by Buddha443556 on Wed, 13 Oct 2021 03:28:03 +0300

Algorithm efficiency and elementary sorting

Reference from: Algorithm column catalogue 1, Time complexity 1. Algorithm efficiency 2. Time complexity   3. Comparison of time complexity 2, Elementary sorting 1. Insert sort 2. Hill sort 3. Bubble sorting 4. Quick sort 5. Merge and sort 6. Select sort 7. Heap sorting 8. Count sorting 9. Bucket sorting 10. Cardinality sor ...

Added by YorkshireSteve on Tue, 12 Oct 2021 21:54:53 +0300