[sword finger Offer 54. The k-th node of binary search tree]

Title Description: Source: LeetCode Link: https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof Given a binary search tree, please find the value of the k-largest node. Example: Example 1: input: root = [3,1,4,null,2], k = 1 3 / \ 1 4 \ 2 output: 4 Example 2: input: root = [5,3,6,2,4,null, ...

Posted by straycat on Thu, 24 Feb 2022 16:41:52 +0100

Leetcode notes -- Introduction to greedy algorithm

Catalogue of series articles I Array type problem solving method 1: dichotomy II Array type problem solving method 2: Double finger needle method III Array type problem solving method 3: sliding window IV Array type problem solving method 4: simulation V The basic operation and classic topics of the linked list Vi Classic title of hash tab ...

Posted by hopelessX on Thu, 24 Feb 2022 13:02:34 +0100

Leetcode brush questions 05 tree

character string Basic knowledge Definitions and related concepts 1. Linked list and diagram Single linked list: one data field + one pointer field Tree: one data field + multiple pointer fields Figure: vertex set + edge Tree: acyclic connected graph is a special kind of graph. 2. Definition of tree A tree is a finite set of N (N &gt ...

Posted by rosegarden on Wed, 23 Feb 2022 12:59:08 +0100

Day 5 of Leetcode algorithm Introduction (double pointer)

876. Intermediate node of linked list Title Description Given a non empty single linked list with head node, return the intermediate node of the linked list. If there are two intermediate nodes, the second intermediate node is returned. Sample Input:[1,2,3,4,5] Output:[3,4,5] Explanation: the returned node value is 3 (The serializatio ...

Posted by eazyefolife on Wed, 23 Feb 2022 09:54:43 +0100

LeetCode 688. Knight's probability on the chessboard / 1791 Find the central node of the star chart / 969 Pancake sorting (bubble sorting)

688. Knight's probability on the chessboard 2022.2.1 one question per day Title Description On an n x n chess board, a knight starts from a row (column) and tries to make k moves. Rows and columns start at 0, so the upper left cell is (0,0) and the lower right cell is (n - 1, n - 1). Chess knight has 8 possible walking methods, as shown in ...

Posted by belayet on Wed, 23 Feb 2022 03:12:34 +0100

day6 list job

1. Basic questions Given a list of numbers, print all odd numbers in the list list1=[22,33,45,67,78] for x in list1: if x%2 !=0: print(x) Given a list of numbers, print all the numbers in the list that can be divided by 3 but cannot be divided by 2 list2=[2,3,6,8,9,10] for x in list2: if x%3==0 and x%2 !=0: print(x) ...

Posted by asherinho on Tue, 22 Feb 2022 13:46:02 +0100

[binary tree] Morris traversal -- an traversal method without auxiliary space

preface Traversal of binary tree is an unavoidable problem to solve the related problems of binary tree. Many problems are solved on the basis of traversal. According to different problems, we can use different traversal methods. According to the order of operations on the root node, it can be divided into: Preorder traversal Middle order tra ...

Posted by md7dani on Tue, 22 Feb 2022 09:55:53 +0100

LeetCode1994. Number of good subsets - shape pressure DP

Number of good subsets   the data range of this question is relatively small, which determines that state compression dp can be used.    to split the product of all numbers in the subset into different prime factors, the subset must hold different prime factors, and each element subset cannot hold duplicate prime factors. &emsp ...

Posted by cdennste on Tue, 22 Feb 2022 09:55:32 +0100

Path in [LeetCode] matrix & & motion range of robot

34.Path in matrix Title: Given an m x n two-dimensional character grid board and a string word word. If word exists in the grid, return true; Otherwise, false is returned. Words must be formed alphabetically by letters in adjacent cells, where "adjacent" cells are those horizontally or vertically adjacent. Letters in the same cell c ...

Posted by jjacquay712 on Tue, 22 Feb 2022 08:34:54 +0100

Simple understanding of sorting algorithm

Before carrying out many convenient algorithms, it is always necessary to realize the ordering of objects, which will use the sorting related algorithms. Even though many high-level languages have completed the encapsulation of the sorting algorithm, users only need to import the corresponding library file to call the sorting algorithm to compl ...

Posted by texerasmo on Mon, 21 Feb 2022 14:23:38 +0100