Leetcode 746. Climbing stairs with minimum cost (dynamic programming method and optimization solution)

Title address Leetcode 746. Climb stairs with minimum cost Title Description Give you an integer array cost, where cost[i] is the cost of climbing up the ith step of the stairs. Once you pay this fee, you can choose to climb up one or two steps. You can choose to climb the stairs from the steps with subscript 0 or subscript 1. Please calc ...

Added by gladius on Sun, 27 Feb 2022 05:03:42 +0200

Knapsack problem C++

Convenient for self review == 1.01 Backpack Problem Description: there are n valuable items and a backpack with a volume of v. there is one for each item. Calculate the maximum value of the items that the backpack can hold. Analysis process: 1. Describe the state: we use f [i] [j] to indicate that only the first I items are selected, and th ...

Added by adam119 on Sat, 26 Feb 2022 17:19:35 +0200

Leetcode notes -- basic topics of dynamic programming

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 ...

Added by Redapple on Fri, 25 Feb 2022 15:35:16 +0200

LeetCode 1706. Where does the ball meet? Multiple solutions to one problem

1706. Where does the ball meet Problem solution Title Source: 1706. Where does the ball meet 2022.02.24 one question per day Daily question column address: LeetCode daily problem solution is being updated ❤️💕 Today's topic is easier. After solving the problem, I'll pack my bags and go back to school tomorrow. I hope it's easy tomorrow, heh ...

Added by fredcool on Thu, 24 Feb 2022 12:28:42 +0200

Traveling salesman problem (TSP) like code

Definition from Wikipedia The travelling salesman problem (also called the travelling salesperson problem or TSP) asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city?" Recently, in order to ...

Added by android6011 on Wed, 23 Feb 2022 14:02:53 +0200

Binary tree topic 03

Question 1: Question 617 of force deduction Problem solving ideas: reference This article The code is as follows: class Solution { public TreeNode mergeTrees(TreeNode root1, TreeNode root2) { if(root1 == null) { return root2; } if(root2 == null) { return root1; } TreeNode r ...

Added by guiltyspark on Mon, 21 Feb 2022 14:35:22 +0200

Blue Bridge Cup ALGO-1006 gold coin dynamic programming double solution

subject analysis This is a typical example of dynamic programming. The optimal substructure should be selected at each step, that is, the lattice that can get the most gold coins. Here are two ideas to solve this problem: backtracking and dp array. These two ideas can be said to find the optimal solution in the opposite way, one from top t ...

Added by joeami on Sun, 20 Feb 2022 06:29:30 +0200

Algorithm analysis and Design Experiment 3 dynamic programming

Experimental environment Windows 10+DEV-C++ dynamic programming Dynamic programming is a hot topic in algorithm design and analysis. If the optimal solution of a problem (usually the maximum or minimum value) is required, and the problem can be decomposed into several problems, and there are overlapping subproblems between small problems ...

Added by reub77 on Sat, 19 Feb 2022 12:11:44 +0200

LeetCode problem solution - dynamic programming - subsequence problem

LeetCode problem solution - dynamic programming - subsequence problem Reference: labuladong WeChat official account, hand handle brush, dynamic programming series, official account, excellent public address, recommended to everyone. In this paper, we will pick up the routine of sub sequence problem. In fact, there are two kinds of templ ...

Added by reversenorm on Sat, 19 Feb 2022 09:52:48 +0200

codeforces (sort + 01 backpack)

1. Problem Description: Niuniu is playing a CF game. The game time is T minutes. There are N questions. You can submit the code at any time during the game time. The score of question I is maxPoints[i]. The score of question I decreases by pointsPerMinute[i] per minute with the progress of the game. This is a CF game of dark. The score may be ...

Added by colemanm on Sat, 19 Feb 2022 09:32:13 +0200