First knowledge of "backtracking algorithm" and analysis of LeetCode examples

Backtracking algorithm 1. Concept of backtracking algorithm xxxx backtracking algorithm is also called heuristics. It is a method to systematically search the solution of the problem. The basic idea of backtracking algorithm is: go forward from one way, go in if you can, go back if you can't, and try another way. xxxx the above text is so ...

Posted by thyscorpion on Tue, 21 Sep 2021 14:45:07 -0700

leetcode brush record day006:48 and 344

48. Medium difficulty: Requirement: rotate the image in place Method 1: clockwise circulation from outside to inside: class Solution { public void rotate(int[][] matrix) { if(matrix.length == 0 || matrix.length != matrix[0].length) { //If the array passed is not equilateral or the element is 0, it is returned return; ...

Posted by tablex on Tue, 21 Sep 2021 02:01:29 -0700

Should C + + return an object or a pointer to the object when brushing questions?

This paper only discusses whether to return the object or the pointer of the object when writing algorithm problems in C + +. As we all know, C + + variables are different from java and python. C + + variables are not natural pointers, so the assignment between object type variables is much more time-consuming than java and python. For example ...

Posted by AnnieKay on Mon, 20 Sep 2021 23:04:34 -0700

[sword finger Offer] search and backtracking

Li Kou's notes have been opened to the public: Portal [Author: ArtBoy literature and art Self-Improvement There's no better way to overpower a trickle of doubt than with a flood of naked truth. A flood of facts is the best way to break a trace of doubt. Title Source: https://leetcode-cn.com/leetbook/detail/illustration-of-algorith ...

Posted by garmann on Mon, 20 Sep 2021 22:42:42 -0700

leetcode daily question: 1002. Find common characters

leetcode daily question: 1002. Find common characters Title Description: given A string array A composed of only lowercase letters, return A list composed of all characters (including repeated characters) displayed in each string in the list. For example, if A character appears 3 times in each string, but not 4 times, you need to include th ...

Posted by cwiddowson on Sun, 19 Sep 2021 21:26:59 -0700

list array simple exercise 2

1. Convert an ordered array into a binary search tree Give you an integer array nums, in which the elements have been arranged in ascending order. Please convert it into a highly balanced binary search tree. A height balanced binary tree is a binary tree that satisfies the requirement that the absolute value of the height difference between t ...

Posted by hanhao on Sun, 19 Sep 2021 19:49:49 -0700

The longest absolute path to the file

subject Assume that the file system is as shown in the figure below: Here, dir is the only directory in the root directory. Dir contains two subdirectories, subdir1 and subdir2. Subdir1 contains the file file1.ext and subdirectory subdir1; Subdir2 contains the subdirectory subdir2, which contains the file file2.ext. In the text format, as f ...

Posted by br0ken on Sun, 19 Sep 2021 17:43:35 -0700

Fundamentals of binary search algorithm

In binary search, the definition of the search interval of the target element is very important, and the definitions of different intervals are written differently. Because the search interval is iterative, it is very important to determine the search range, mainly the opening and closing of the left and right intervals. The opening and closing ...

Posted by audiodef on Sun, 19 Sep 2021 11:05:30 -0700

LeetCode 005 string series

String (3) Hello, everyone! I'm Xiao Sheng! I was busy learning java back-end technology, delayed the update of algorithm topics, and was ashamed to set up a weekly brushing plan to break through. Now I'm on the road of brushing again, keep it up! Go on! String (3) Series of questions as follows Subsequence (392) 392. Judgment Subseq ...

Posted by brainstorm on Sat, 18 Sep 2021 11:41:23 -0700

[out of order version ● sword finger offer] daily algorithm problem punch in problem solution - dynamic programming (topic No. 42,46,47,48)

Punch in day7 Question 1: Sword finger Offer 42. Maximum sum of continuous subarrays Enter an integer array. One or more consecutive integers in the array form a sub array. Find the maximum value of the sum of all subarrays. The required time complexity is O(n). Example 1: Input: num = [- 2,1, - 3,4, - 1,2,1, - 5,4] Output: 6 Explana ...

Posted by GravityFX on Fri, 17 Sep 2021 09:19:17 -0700