Tag：This topic

Time：202171
Title addresshttps://leetcodecn.com/problems/invertbinarytree/ 1. Recursion Time complexity O (n) space complexity O (n)The idea of recursion is to find the termination condition of recursion. The termination condition of recursion can only end recursion if the current node is null. Or we can think about it from another perspective. If this node is not null, it may […]

Time：2021611
Title addresshttps://leetcodecn.com/problems/maximumdepthofbinarytree/ 1. Recursion Time complexity O (n) space complexity O (H), space complexity is mainly used for recursive stack depth HIt’s very simple to use recursion to solve the problem locally. The first condition of recursion termination is recursion to the current node is null. var maxDepth = function(root) { if (root === null) […]

Time：202168
Title addresshttps://leetcodecn.com/problems/symmetrictree/ 1. Recursion As like as two peas, the two most identical trees are mirrored. The relationship between them is satisfiednode1.left == node2.rightAndnode1.right == node2.leftThe time complexity O (n) n is the number of nodes; The space complexity O (H) H is the maximum depth of binary tree class Solution { public boolean isSymmetric(TreeNode […]

Time：202136
Title: masseuse A famous masseuse will receive a steady stream of appointment requests, each appointment can choose to accept or not. There is a break between each appointment, so she can’t accept adjacent appointments. Given an appointment request sequence, find the optimal appointment set for the masseuse (the total appointment time is the longest), […]

Time：2021216
Title: Life Game According to Baidu Encyclopedia, life game, referred to as life, is a cellular automata invented by British mathematician John Houghton Conway in 1970. Given a panel containing m × n lattices, each lattice can be regarded as a cell. Each cell has an initial state: 1 is live cell, or 0 is […]

Time：202066
Example 7 summation of series Title Description Known: Sn=1+1/2+1/3+… +1/n。 Obviously for any integer k, when n is large enough, sn>k。 In this paper, we give an integer k, which requires to calculate a minimum n, so that sn>k。 Input format A positive integer k Output format A positive integer n sample input 1 sample […]

Time：202063
This problem requires programming to find the minimum value in a given series of integers. Input format: The input first gives a positive integer n in a row, followed by N integers, separated by spaces. Output format: Output the minimum value of N integers in the format of “Min = minimum value” in one line. […]