Tag:This topic

  • Leetcode-0226 flipped binary tree

    Time:2021-7-1

    Title addresshttps://leetcode-cn.com/problems/invert-binary-tree/ 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 […]

  • The maximum depth of leetcode-0104 binary tree

    Time:2021-6-11

    Title addresshttps://leetcode-cn.com/problems/maximum-depth-of-binary-tree/ 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) […]

  • Leetcode-0101 symmetric binary tree

    Time:2021-6-8

    Title addresshttps://leetcode-cn.com/problems/symmetric-tree/ 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 […]

  • [caption - dynamic programming - interview] masseuse – leetcode

    Time:2021-3-6

    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), […]

  • [caption] life game – leetcode

    Time:2021-2-16

    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 […]

  • 100 cases of C programming (7): summation of series

    Time:2020-6-6

    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 […]

  • Exercise 4-10 find the minimum (20 points)

    Time:2020-6-3

    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. […]