Bailian 4116 rescue action & & 4130 Saving Tang Monk&&4115 Naruto and Sasuke simple BFS search question summary and comparison

I Bailian 4116 rescue operation( OpenJudge - 4116: rescue operations) This problem is to add a guard on the basis of simple BFS. Killing a guard also needs + 1. Others can follow the idea of ordinary BFS as usual. The most important thing is that killing a guard can be regarded as a point after twice, so there is no need to deal with killing ...

Added by korion on Fri, 14 Jan 2022 15:16:34 +0200

P2962 [usaco09nov] lights G

P2962 [USACO09NOV]Lights G Luogu Source: P2962 [USACO09NOV]Lights G Meaning: Given n points, the initial value is 0, m undirected edges, operate one point at a time, change itself and the point 1 connected to itself into 0, 0 into 1, and ask the minimum number of operations, so that all are 1 Idea: I think the bosses are written by Gaus ...

Added by sunil.23413 on Fri, 14 Jan 2022 15:02:10 +0200

Data structure and algorithm

** Infix to suffix expression ** 1, Suffix expression evaluation The suffix expression is also called inverse Polish expression, and its evaluation process can use the stack to assist storage. Assuming that the suffix expression to be evaluated is 6 5 2 3 + 8 * + 3 + *, the evaluation process is as follows: 1) When traversing the expression, ...

Added by mega_hurtz on Fri, 14 Jan 2022 11:23:33 +0200

Leetcode.1743. Why is it so fast to restore the HashMap value of the array from adjacent element pairs?

1, Leetccode1743 multiple processing methods On the third day, I found that the first question in the leetcode question bank was given randomly every day. Two simple questions were given to me two days ago. Today, I came directly to a medium question. Adhering to the ability to cultivate algorithmic thinking and independent thinking, I ...

Added by Wardy7 on Fri, 14 Jan 2022 09:55:30 +0200

Algorithm practice - Z-font transformation

Z-font Transformation: The solution of this problem is only for personal understanding. If there are other ideas or solutions, welcome to explore! Buckle link: Z igzag transformation Title: A given string s is arranged in a zigzag manner from top to bottom and from left to right according to the given number of rows numRows. For e ...

Added by blaster_master on Fri, 14 Jan 2022 09:05:19 +0200

Java design pattern - composite pattern

Combination mode Business requirements The school displays the structure of colleges and departments. A school has multiple colleges and a college has multiple departments;Traditional thinking, the Department inherits the college, and the college inherits the school; problem analysis The college is regarded as a subclass of the school, and ...

Added by schoi on Fri, 14 Jan 2022 06:33:44 +0200

Data structure and algorithm learning notes: Cheng Jie's Dahua data structure

Data structure and algorithm learning notes: Cheng Jie's Dahua data structure Chapter 1 data structure introduction Data item: the smallest indivisible unit of data. In the course of data structure, defining data items as the smallest unit helps us solve problems better. But when we really discuss the problem, the data element is the focus of ...

Added by ram4nd on Fri, 14 Jan 2022 04:35:03 +0200

Binary tree 14: same tree

LeetCode485: given two binary trees, write a function to check whether they are the same. If two trees are structurally identical and the nodes have the same value, they are considered to be the same. For example: 1. Recursive solution It seems that two binary trees perform preorder traversal at the same time. First judge whether the root ...

Added by rcity on Fri, 14 Jan 2022 00:43:08 +0200

Introduction to dynamic programming (knapsack problems such as 0-1 knapsack)

Basic idea of dynamic programming Understand the basic idea of dynamic programming Determine state variables (functions)Determine the state transition equation (recursive relationship)Determine boundary Various knapsack problem contents, ideas, examples and code implementation Basic 0-1 knapsack problem The basic idea of 0-1 knapsack probl ...

Added by Haggen on Thu, 13 Jan 2022 18:23:28 +0200

Serialization and deserialization of binary tree

Definition of serialization: Serialization refers to the process of converting the data structure or object state into a usable format (e.g. stored as a file, buffered, or sent over the network) for subsequent recovery in the same or another computer environment. When the byte result is retrieved according to the serialization format, it can b ...

Added by ccb on Thu, 13 Jan 2022 17:23:49 +0200