Combination of KMP with AC automata and DP

Design password Now you need to design a password S , S S,S S. S needs to meet: S The length of the is N; S Contains only lowercase English letters; S Contains no substrings T; For example: ...

Added by cjacks on Wed, 22 Sep 2021 01:23:51 +0300

LeetCode skimming - find the central index of the array

This is the 1st / 100th question that I insist on swiping the card~   1, Title Description Give you an integer array nums, please calculate the central subscript of the array. The central subscript of the array is a subscript of the array. The sum of all elements on the left is equal to the sum of all elements on the right. If the centra ...

Added by vasoftwaresolutions on Tue, 21 Sep 2021 11:36:52 +0300

Depth first traversal and breadth first traversal of Graphs

Drawing out: we learned linear tables and trees earlier. The linear table is limited to the relationship between a direct precursor and a direct successor; The tree can only have one direct precursor, that is, the parent node. However, when we need to represent many to many relationships, we need to use the data structure of graph. There are ...

Added by l00ph0le on Tue, 21 Sep 2021 06:08:08 +0300

Application of [machine learning practice task 1] (KNN) k nearest neighbor algorithm

1 background 1.1 overview of k-nearest neighbor algorithm (1) Introduction of k-nearest neighbor algorithm k-nearest neighbor algorithm is a very effective and easy to master machine learning algorithm. In short, it is an algorithm to classify data by measuring the distance between different eigenvalues. (2) Working principle of k-nearest n ...

Added by Jaehoon on Tue, 21 Sep 2021 02:58:51 +0300

Backtracking algorithm -- elaboration from the "0-1 knapsack" problem

Backtracking algorithm "It is common in the world that if you don't advance, you will retreat, if you don't like it, you will worry, and if you don't have it, you will die." --- Deng Xizi · Chapter II preface Backtracking method is known as the universal solution, and it also contains the life philosophy of taking a st ...

Added by jasons61 on Mon, 20 Sep 2021 22:59:38 +0300

Sequence table partial pseudo code

Sequence table partial pseudo code 2. Delete the element with the minimum value from the sequence table (assuming unique) and return the deleted element by the function. The empty position is filled by the last element. If the sequence table is empty, an error message will be displayed and the operation will exit. Writing thought: typedef st ...

Added by tphgangster on Mon, 20 Sep 2021 14:06:27 +0300

[algorithm] Analysis on the use of fast power operation in JavaScript

start Find the n-th power of x (just talk about n nonnegative first) Violent solution x n = x ⋅ x ⋅ ...

Added by Eugene on Mon, 20 Sep 2021 12:09:12 +0300

3 shortest circuit problem

11.3 shortest circuit problem In Chapter 9, we introduce the shortest path and longest path problem on weighted DAG and weighted DAG. Here we add rings to the graph. 11.3.1 Dijkstra algorithm Dijkstra algorithm is applicable to the case where the edge weight is positive. It can be used to calculate the single source shortest path on the po ...

Added by guestabc on Mon, 20 Sep 2021 09:41:32 +0300

Sword finger Offer: various abilities in interview

Sword finger Offer 53 - I. find the number I in the sorted array Counts the number of times a number appears in the sorted array. Problem solving idea: binary search class Solution { public int search(int[] nums, int target) { if(nums==null||nums.length==0||target<nums[0]||target>nums[nums.length-1])return 0; in ...

Added by eaglelegend on Sun, 19 Sep 2021 22:51:53 +0300

Strategy mode and responsibility chain mode

1, Strategy mode Strategy Pattern, also known as policy pattern, encapsulates the defined algorithm families and so that they can be replaced with each other, so that the change of the algorithm will not affect the users using the algorithm. It belongs to behavioral mode. Define a family of algor ithms, encapsulate each one, and make them ...

Added by dansk on Sun, 19 Sep 2021 17:09:23 +0300