Dancing Links algorithm -- finding accurate coverage

Precise coverage problem: Given a matrix composed of 0 and 1, can we find a set of rows so that each column in the set contains exactly one 1. This kind of problem is a classical exact covering problem, which belongs to NP complete problem without polynomial algorithm. Backtracking exhaustive: Select the first row (red), and the elements t ...

Added by beginneratphp on Wed, 02 Feb 2022 02:11:54 +0200

C language: L2-006 tree traversal (25 points)

1, Title Given the post order traversal and middle order traversal of a binary tree, please output the sequence of its sequence traversal. It is assumed that the key values are positive integers that are not equal to each other. Input format: The first line of input gives a positive integer N (≤ 30), which is the number of nod ...

Added by scottfossum on Wed, 02 Feb 2022 00:17:05 +0200

Analysis and application of binary search

Look at leetcode Given an array containing n positive integers and a positive integer target. Find out the continuous sub array [numsl, numsl+1,..., numsr-1, numsr] with the smallest length satisfying its sum ≥ target in the array, and return its length. If there is no eligible subarray, 0 is returned. Example 1: Input: target = 7, Num ...

Added by sharugan on Tue, 01 Feb 2022 23:19:04 +0200

JAVA exercise 71 - longest substring

When the uppercase and lowercase forms of each letter contained in a string s , appear in s , at the same time, the string s , is called a beautiful string. For example, "abABB" is a beautiful string, because 'a' and 'a' appear at the same time, and 'B' and 'B' appear at the same time. However, "abA" is not a good string ...

Added by googlit on Tue, 01 Feb 2022 22:04:27 +0200

Detailed implementation of common load balancing algorithms

catalogue background 1, Polling algorithm Implementation principle 2, Random algorithm Implementation principle 3, Hash algorithm Implementation principle 4, Weight algorithm Implementation principle 5, Using unit tests polling random Hash weight background With the advent of the era of large database, many distributed applica ...

Added by jungalist on Tue, 01 Feb 2022 21:50:30 +0200

[C + +] [binary tree] [binary search tree] build a binary search tree class.

1, Key analysis 1. Insert node Inserting a node is relatively simple. You only need to judge the key value, replace the corresponding key value, or create a new key value. // Insert the node (key, value) into the binary search tree with node as the root, and use the recursive algorithm // Returns the root of the binary search tree ...

Added by dietkinnie on Tue, 01 Feb 2022 21:46:07 +0200

Dp from introduction to mastery 2.1 (linear DP, ascending subsequence, common subsequence)

emmm,dp problem is really magical. If you want to get the equation of state, you can take off immediately. If you can't think of it and have no idea, then It is suggested to write after a good meal. It may be faster In fact, dp is more an experience. If you see more, you will write faster, because the state of this kind of questions means that ...

Added by skovela on Tue, 01 Feb 2022 19:06:07 +0200

Codeforces Round #769 (Div. 2): E1. Distance Tree (easy version)

Distance tree Limited ability, only understand easy version Meaning: Given a tree with n nodes, d ( v ) d(v) d(v) represents the shortest distance from any point to 1 po ...

Added by arianhojat on Tue, 01 Feb 2022 18:33:05 +0200

Interval DP: Gene splicing

5 (optional) gene splicing (100 points) Gene splicing is the joining of different DNA fragments. The existing n DNA fragments line up from left to right. Each time two adjacent DNA fragments were selected and stitched into a longer DNA fragment. The last DNA fragment was adjacent to the first. Repeat this process until all the DNA fragments for ...

Added by dookie on Tue, 01 Feb 2022 17:50:26 +0200

leetcode day 19 - 884438713209

Day 19 884 unusual words in two sentences A sentence is a string of words separated by spaces. Each word consists of only lowercase letters. If a word happens to appear once in one sentence but does not appear in the other sentence, the word is not common. Give you two sentences s1 and s2 and return a list of all the infrequently used words ...

Added by mahakmx on Tue, 01 Feb 2022 13:01:53 +0200