Topology sorting, critical path

         Topological sorting What is topological sorting?     in graph theory, topological ordering is a linear sequence of all vertices of a directed acyclic graph (to obtain a topological ordered sequence). And the sequence must meet the following two conditions: Each vertex appears only once.If there is A path from vertex ...

Added by lala on Sat, 18 Dec 2021 15:16:50 +0200

[solution] [AcWing] 1601. Online map

1601. Online map Original question transmission: AcWing 1601. Online map Enter our current location and destination, and the online map can recommend some routes. Now your job is to recommend two routes to users: one is the shortest route and the other is the fastest route. Ensure that there is at least one route between the two places for ...

Added by jlp09550 on Sat, 18 Dec 2021 11:40:20 +0200

Nearest Beautiful Number (easy version) (hard version)

Portal Solution: Look directly at the hard version. I feel that easy is not very different from the hard version. To get the minimum k-beautiful number, it can be divided into the following two cases. First of all, if K is greater than or equal to the number of different bits after n is converted into a string, then directly output this n. t ...

Added by Goop3630 on Sat, 18 Dec 2021 06:22:31 +0200

The three most classic containers in C + + are Vector, Map and List

There are many kinds of containers in C + +. The common ones are sequential containers: vector, deque and list. There are also associated containers: set, multiset, map and multimap. There are too many containers. Let's talk about the three most commonly used containers: vector, list and map. First: Vector container Sketch Map: characteris ...

Added by j0hn_ on Sat, 18 Dec 2021 05:23:23 +0200

[optimal location] ant colony algorithm to solve the location optimization problem of electric vehicle charging station and exchange station [matlab phase 1182]

1, Introduction to ant colony algorithm 1 Overview An algorithm designed to simulate ant foraging behavior (shortest path principle). The foraging characteristics of ant groups are abstracted and transformed into mathematical description. • ant colony algorithm (ACA) was first proposed by Marco Dorigo in his doctoral thesis in 1992. &bu ...

Added by rdawson on Sat, 18 Dec 2021 02:13:10 +0200

Java post development for 3 years, the company's temporary spot check algorithm, I remember these questions after leaving for a lifetime, from shallow to deep

A few days ago, our company did a stupid thing, a very, very stupid thing. I thought that after I came out of school, there would be nothing related to the exam except for the test of finding a job. However, there was an unexpected situation. The technical director and personnel director of the company suddenly came to our business line, call ...

Added by knobby2k on Sat, 18 Dec 2021 02:02:36 +0200

JavaScript data structure and algorithm

JavaScript data structure and algorithm (I) Preface: This article mainly explains and discusses the common data structures in programming languages, and uses JavaScript for encapsulation, because as we all know, JavaScript is a weak type language, not only does not have type detection, but also some practical and efficient data structures such ...

Added by whare on Sat, 18 Dec 2021 01:49:43 +0200

LeetCode 169. Most elements (hash table)

subject Given an array of size n, find most of its elements. Most elements refer to elements that appear more than ⌊ n/2 ⌋ in the array. You can assume that the array is non empty and that there are always many elements in a given array. Example 1: Input:[3,2,3] Output: 3 Example 2: Input:[2,2,1,1,1,2,2] Output: 2 P ...

Added by johnnyk on Sat, 18 Dec 2021 00:46:15 +0200

Reverse linked list problem

1 recursively reverse the entire linked list For recursive algorithms, the most important thing is to clarify the definition of recursive functions. Specifically, our reverse function is defined as follows: Enter a node head,take「with head As the starting point」The linked list of is inverted and returns the head node after inversion. Und ...

Added by stickynote427 on Sat, 18 Dec 2021 00:39:12 +0200

(Maximum Subarray) maximum suborder sum

Title: Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Given an integer array nums, find a continuous sub array with the largest sum (the sub array contains at least one element) and return its maximum sum. E ...

Added by andreiga on Fri, 17 Dec 2021 23:39:15 +0200