Under a more detailed classification, there are three common types of greedy questions
Under a more detailed classification, there are three common types of greedy questions
Greed is an idea that constantly selects the local optimal solution to achieve the global optimal solution. In other words, greed is constantly making the most favorable decisions for the present. It is unrealistic to classify all greedy problems in o ...
Posted by maxat on Thu, 10 Mar 2022 14:00:19 +0100
Solution to 45 A-E questions of Niuke monthly competition
preface
link Niuke Xiaobai monthly race 45
Finish five questions for the first time hh
Try to write a solution
The codes are directly copy the game time codes, which may be messy
I'll try to write notes hh If you have any questions, please point them out hh
A
This problem is difficult to read...
If n > = x Then you can jump horizont ...
Posted by jameslynns on Fri, 04 Mar 2022 22:52:21 +0100
[Blue Bridge Cup] Q & A
answering question
have
n
n
n students asked the teacher to answer questions at the same time. Each student has estimated the time of answering questions in advance.
The teacher can arrange the order of answering questions, and the students should enter the teach ...
Posted by imderek on Sun, 27 Feb 2022 05:08:29 +0100
Greed -- Huffman tree: merging fruits
Basic concepts
Path: the path from one node to another in a tree is called a path. In the following figure, the path from the root node to node a is a path. Path length: in a path, the path length should be increased by 1 for each node. For example, in a tree, if the number of layers of the root node is specified as 1, the path length from t ...
Posted by chriskl on Fri, 25 Feb 2022 16:12:46 +0100
Leetcode notes -- Introduction to greedy algorithm
Catalogue of series articles
I Array type problem solving method 1: dichotomy II Array type problem solving method 2: Double finger needle method III Array type problem solving method 3: sliding window IV Array type problem solving method 4: simulation V The basic operation and classic topics of the linked list Vi Classic title of hash tab ...
Posted by hopelessX on Thu, 24 Feb 2022 13:02:34 +0100
2022-02-22 swipe questions and punch in every day
2022-02-22 swipe questions and punch in every day
All in one -- dynamic programming
1268: [example 9.12] complete knapsack problem
[Title Description]
There are n kinds of articles, each of which has a weight and a value. However, the number of each item is unlimited. At the same time, there is a backpack with a maximum carrying capacity of ...
Posted by remmy82 on Tue, 22 Feb 2022 08:08:44 +0100
[code Capriccio] Chapter 10 greedy algorithm
Chapter 10 greedy algorithm
Greed has no fixed template routine
If we can find out the local optimum and deduce the global optimum, it is greedy; If the local optimum is not found, it is not greedy, but may be a simple simulation.
Greedy algorithm is generally divided into the following four steps:
The problem is decomposed into several sub ...
Posted by aaaaCHoooo on Mon, 21 Feb 2022 09:23:53 +0100
Luogu P1926 little schoolboy - question brushing Army
P1926. Little schoolboy - question brushing Army
subject
Topic background
Mathematics is fire, lighting up the lamp of physics; Physics is a lamp, illuminating the way of chemistry; Chemistry is the road leading to the pit of biology; A creature is a pit, burying a man of reason. Classical Chinese is fire, lighting up the palace lamp of hist ...
Posted by eddiegster on Thu, 17 Feb 2022 08:48:27 +0100
861. Score after flipping the matrix
Address:
Force bucklehttps://leetcode-cn.com/problems/score-after-flipping-matrix/
Title:
There is A two-dimensional matrix , A, where the value of each element is , 0 , or , 1.
Move refers to selecting any row or column and converting each value in the row or column: change all 0 to 1 and all 1 to 0.
After making any number of moves, ...
Posted by Vivid Lust on Sun, 13 Feb 2022 10:16:31 +0100
Three solutions to change in Python
Change
The most direct solution to the change problem is the greedy strategy. For example: for coins with face values of 1, 5, 10 and 25, solve the minimum number of coins required to exchange 63 yuan.
The idea of greedy strategy is to constantly use the coins with the largest face value to try. No, in this case, 25 coins are used to try the ...
Posted by dbrimlow on Sat, 12 Feb 2022 08:55:23 +0100