Leetcode problem solving series -- symmetric binary tree (recursion)

This topic aims to share some interesting or valuable topics found in the process of brushing Leecode. [answer based on js, of course].Recursive algorithm has always been one of the key types of leetcode medium difficulty exercises, so the key is self-evident.Topic relatedOriginal address: https://leetcode-cn.com/problems/dui-cheng-de-er-cha-sh ...

Posted by godwisam on Thu, 27 Jan 2022 15:12:33 +0100

Binary tree recursive routine: judge whether it is a full binary tree and the number of nodes of the largest sub search binary tree

Today, continue the recursive routine of binary tree.1, Determine whether it is a full binary treeFull binary tree definition: for a binary tree with height h, the number of nodes is (2^h - 1)1. Recursive routine ideaAccording to the definition of full binary tree, we only need to obtain the height and the number of nodes each time.That is, we ...

Posted by elementaluk on Tue, 25 Jan 2022 04:46:06 +0100

LeetCode_LinkedList_92. Reverse Linked List II (C++/Java) [recursion]

catalogue 1, Title Description English description Chinese description 2, Problem solving ideas 3, AC code C++ Java 4, Problem solving process First Bo   1, Title Description English description Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from posi ...

Posted by taz321 on Sun, 23 Jan 2022 04:30:06 +0100

Binary tree recursion routine: judge whether the binary tree is a complete binary tree and whether the binary tree is a balanced binary tree

We are already familiar with the basic routine of binary tree. Next, let's talk about the recursive routine of binary tree, which can solve most binary tree problems in the interview, especially the tree dp problem. Its essence is to use the convenience of recursion to traverse binary tree.Judge whether the binary tree is a complete binary tree ...

Posted by hip_hop_x on Mon, 17 Jan 2022 18:02:57 +0100

Binary tree and path for a certain value - byte jump written test programming C/C++

Title Description Enter the root node root and an integer expectNumber of a binary tree to find all paths where the sum of node values in the binary tree is expectNumber. 1. The problem path is defined as the node from the root node of the tree to the leaf node (cat bin roars and prompts: pay great attention here - you must go to the leaf no ...

Posted by ziltech on Tue, 04 Jan 2022 15:25:56 +0100

Python learning log 10 - higher order functions and advanced applications

Python learning log Home page of RBHGO Welcome to pay attention Warm tip: creation is not easy. If reprinted, indicate the source. Thank you for your cooperation~ catalogue preface Last time we shared functions, we also talked about the data types commonly used in Python. These types of variables can be used as parameters or retu ...

Posted by mrbaseball34 on Sun, 02 Jan 2022 19:11:40 +0100

Algorithm recursion

reference resources Boss blog 1. Understanding of recursion Recursion is to call our own process. We don't have to worry about what each level does. We just need to pay attention to the implementation of a certain level, because each level is the same!!! Recursion can be seen as a simplified version of a loop, and the essence of recursion ca ...

Posted by stanleybb on Mon, 27 Dec 2021 08:44:53 +0100

LeetCode 112. Path sum [c++/java detailed problem solution]

1. Title Give you the root node root of the binary tree and an integer targetSum representing the target sum. Judge whether there is a path from the root node to the leaf node in the tree. The sum of all node values on this path is equal to the target and targetSum. A leaf node is a node that has no children. Example 1: Input: root = ...

Posted by harman on Sun, 19 Dec 2021 07:36:00 +0100

Topic summary of recursive backtracking (issue 4)

Directions for the first three phases: Phase I Phase II Phase III This should be the last issue of backtracking. The previous topics are more conventional, basically what subset or arrangement of written language. This issue summarizes some topics that prefer application. Of course, the essence is still that set. Examples Letter combinati ...

Posted by nmal on Sat, 18 Dec 2021 10:38:07 +0100

LeetCode-131 split palindrome string

Split palindrome string Title Description: give you a string s. please divide s into some substrings so that each substring is a palindrome string. Returns s all possible segmentation schemes. A palindrome string is a string that reads the same forward and reverse. See LeetCode's official website for an example. Source: LeetCode Link: https:// ...

Posted by depraved on Sun, 28 Nov 2021 03:09:39 +0100