## dfs pruning and iterative deepening and bidirectional dfs

1, Question sequence: 1. Consider how to correctly search out all schemes 2. Consider pruning again
1. Optimize search order In most cases, we should give priority to searching nodes with fewer branches. 2. Eliminate equivalent redundancy For example, if the order is not considered, search by combination 3. Feasibility pruning If a scheme is i ...

Added by **lhaynes** on *Tue, 08 Mar 2022 06:57:00 +0200*

## "LeetCode" game 73 biweekly solution

6024. The number that appears most frequently immediately after the key in the array
Code
class Solution {
public:
int mostFrequent(vector<int>& nums, int key) {
int n = nums.size();
int ans = 0;
unordered_map<int, int> mp;
for (int i = 0; i <= n - 2; i++) {
/* Count the numbe ...

Added by **MLJJ** on *Sun, 06 Mar 2022 17:01:08 +0200*

## Maximum subarray sum (greedy algorithm and dynamic programming method)

Note that you are looking for a continuous array!!
1, Dynamic programming method
class Solution {
public int maxSubArray(int[] nums) {
//Create an array dp as large as nums
int[] dp=new int[nums.length];
//dp[i] represents the sum of the largest subarray of the array ending in num [i]
dp[0]=nums[0];
...

Added by **unclemid** on *Sat, 05 Mar 2022 17:31:24 +0200*

## One of the third written test questions of 2021TX development: Game Club

Topic overview
The game club, as its name suggests, is a club composed of several small games. When players enter the club, they will get a list of games, listing the n small games open in the club today, of which the i small game must beComplete within time (assuming that the player enters the club at time 0, it only takes one unit time to st ...

Added by **uramagget** on *Fri, 04 Mar 2022 03:28:59 +0200*

## Simple greedy strategy

Greed and proof
To choose the greedy strategy, we must first prove that the greedy strategy is correct before we can consider using it. In many cases, the rationality of greed is not obvious, but if we can find a counterexample, it can prove that such greed is not correct.
Fractional Knapsack Problem
Fractional Knapsack Problem When the it ...

Added by **alex_lana** on *Fri, 25 Feb 2022 06:48:11 +0200*

## Training - Enumeration, simulation and sorting

preface
Enumeration and simulation are the most common contents of the Blue Bridge Cup. Then, if you sort, you won't investigate the handwriting of the quick row, but you will check, merge and sort. When the Blue Bridge Cup inspected the line segment tree, most of them were written with violence. Greed and number theory have been investi ...

Added by **phpnewbie1979** on *Thu, 24 Feb 2022 16:36:35 +0200*

## School of magic "difference + greed", "line segment tree + greed", "parallel search + greed" and "Kodori tree"

School of magic
Title Description:
Yako likes to collect visible characters without spaces (ASCII code is 33 ~ 126). In her eyes, the value of a character is its ASCII code size, such as the value of 'a' is 97.
So far, she has collected n visible characters excluding spaces, and the ith character is Si. But she wanted to maximize the val ...

Added by **mattsutton** on *Tue, 22 Feb 2022 15:59:10 +0200*

## Greedy algorithm ----- LeetCode 321 maximum number of splices

Title Description
Given two arrays of length m and N, the elements are composed of 0-9, representing the numbers on each bit of two natural numbers. Now select k (k < = m + n) numbers from the two arrays and splice them into a new number. The numbers taken from the same array are required to maintain their relative order in the origina ...

Added by **sundru** on *Sun, 20 Feb 2022 19:15:15 +0200*

## LDU - May Day holiday training (5.1)

J - Cunning Friends
Game theory:
Main idea of the title: give n buckets, each bucket has several small balls, three people play the game, the first hand operates first, and the remaining two people are a group. If you want the first hand to lose, three people play the game in turn. Each candidate takes out > 0 balls in a bucket. When ...

Added by **pucker22** on *Fri, 18 Feb 2022 11:27:20 +0200*

## [ACWing algorithm basic course]: Chapter 5 - dynamic programming

Knapsack problem ★★★
(1) 0-1 knapsack problem (1 for each item)
Topic introduction sample input
4 5
1 2
2 4
3 4
4 5
output
8
[version 1] two dimensional state definition of 0-1 knapsack problem
f[i][j]: select only the first I items with total volume < = Max of J
State analysis
(1) When the current backpack capacity is insuf ...

Added by **dast** on *Tue, 15 Feb 2022 14:15:19 +0200*