Number of deduction 547 provinces

Topic 1 Force buckle: 547 thinking The classical graph theory problem, because the connection between cities is equivalent to edges and cities are equivalent to points. Joint search set (see my blog for a detailed explanation of parallel search Force buckle 648 redundant connection , which wilUTF-8...

Posted by limke on Wed, 13 Oct 2021 19:54:07 +0530

Recursion and Recursion

Recursion and Recursion (1) Recursion and recursion are the most basic and common algorithms, and their shadows can be seen in many places. Let me show you how to do this. This article is practical and will be expanded in the form of exercises. Say nothing more, let's get started! Recursive - DUTF-8...

Posted by John Canyon on Fri, 05 Nov 2021 22:49:49 +0530

P1460 [USACO2.1] healthy Holstein cows

Title Description Farmer John is proud of having the healthiest cows in the world. He knew the minimum amount of vitamins needed by cattle contained in each feed. Please help the farmer feed his cattle to keep them healthy and minimize the number of kinds of feed fed to the cattle. Give the minUTF-8...

Posted by Pinkmischief on Sat, 19 Mar 2022 12:32:02 +0530

Blue Bridge Cup global warming (bfs+dfs)

9. Global warming You have a picture of NxN pixels of a certain sea area, "." represents the ocean, "#" represents the land, as shown below: ... .##... .##... ...##. ...####. ...###. ... Among them, a piece of land connected in the four directions of "up, down, left and right" forms an island. UTF-8...

Posted by samuelxin on Thu, 12 May 2022 19:28:03 +0530

leetcode: 93. Restore IP address

Topic source Leetcode Title Description class Solution { public: vector restoreIpAddresses(string s) { } }; Topic analysis Two problems need to be solved: How to cutWhether the substring and IP address are legal analysis The first point of backtracking: choice Take "25525511135" as an eUTF-8...

Posted by en on Tue, 17 May 2022 01:08:06 +0530

HDU-2553 N queen problem (recursive backtracking + table printing)

N-queens problem Problem Description N queens are placed on the N*N checkerboard so that they do not attack each other (that is, any two queens are not allowed to be in the same row, the same column, or on the slash at a 45 angle with the checkerboard frame). Your task is to find out how many lUTF-8...

Posted by perrohunter on Tue, 17 May 2022 10:31:43 +0530

leetcode_130_surrounded area_reverse thinking_DFS

topic: Given a two-dimensional matrix containing 'X' and 'O' (the letter O). Find all areas surrounded by 'X' and fill all 'O's in those areas with 'X'. Example: X X X X X O O X X X O X X O X X After running your function, the matrix becomes: X X X X X X X X X X X X X O X X explain: The encloseUTF-8...

Posted by Amitk on Mon, 23 May 2022 12:35:19 +0530

Traversal series of binary tree (non recursive)

Traversal of binary tree: pre order, middle order and post order (the first, middle and last are based on the access order of the root node. The first order is: the root node is at the top; the middle order is: the root node is in the middle; the last order is: the root node is at the end.) LeUTF-8...

Posted by corrupshun on Tue, 24 May 2022 08:05:34 +0530

Figure depth first search (DFS) and breadth first search (BFS) details

1. Representation of drawings1.1 adjacency matrixAdjacency matrix is the sequential storage structure of graph"0" and "1" represent whether the column index node has an edge pointing to the row index node.Code expression: typedef struct{ int edges[maxSize][maxSize];//adjacency matrix int n,e;//UTF-8...

Posted by bilbot on Thu, 26 May 2022 05:49:58 +0530

Dynamic programming_ Leetcode 120. triangle minimum path sum

subject Given a triangle, find the minimum path sum from top to bottom. Each step can only be moved to the adjacent nodes in the next row. Adjacent nodes here refer to two nodes whose subscript is the same as or equal to the subscript + 1 of the previous node. For example, given a triangle: [ [UTF-8...

Posted by maltech on Sat, 28 May 2022 19:52:12 +0530