LeetCode selected questions

1. Sequence zigzag traversal of binary tree Given a binary tree, return the zigzag hierarchical traversal of its node value. (that is, traverse the next layer from left to right, and then from right to left, and so on, alternating between layers). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 T ...

Posted by rdoylelmt on Mon, 23 May 2022 10:16:49 +0300

Analysis and java implementation of search related topics in binary tree in Leetcode

Analysis and java implementation of search related topics in binary tree in Leetcode In fact, there are some miscellaneous problems in this category. It is basically to find some or a specific value in the binary tree. There are many problems. We will summarize them through two or three articles, but generally speaking, it is basically BFS, whi ...

Posted by HavokDelta6 on Mon, 23 May 2022 10:13:08 +0300

Leetcode Best Time to Buy and Sell Stock series topic analysis and java implementation

Leetcode Best Time to Buy and Sell Stock series topic analysis and java implementation The title of this series is to allow us to trade according to restrictions in a continuous period of stock prices to maximize profits. Each derivative title will set some restrictions Best Time to Buy and Sell Stock I Best Time to Buy and Sell Stock II Best ...

Posted by Karlos2394 on Sun, 22 May 2022 21:32:50 +0300

Dynamic Programming II

  Common dynamic programming problems (2) This article is reproduced at GitHub address: https://github.com/CyC2018/CS-Notes/ , only for personal review in the future. Integrated various data, invasion and deletion. Citation analysis: Content from official account article: https://mp.weixin.qq.com/s/lKQI0aS1MBwfPujC-m_zkA Use the dynamic ...

Posted by h123z on Sun, 22 May 2022 21:13:49 +0300

java algorithm dynamic programming

java-Dynamic Programming Algorithms Learning Notes Original: java-Dynamic Programming Algorithms Learning Notes-huster-stl-Blog Park (cnblogs.com)   Dynamic programming is a branch of operational research and a mathematical method to solve the optimization of decision process. Dynamic planning often appears as a test question in written inter ...

Posted by Ruchi on Sun, 22 May 2022 20:51:09 +0300

Analysis of typical examples of acm network flow and cost flow

introduction The general difficulty of the problems of network flow and cost flow type lies in drawing. This paper mainly summarizes the various difficulties encountered by the author in the process of doing exercises and explains them in the form of examples. On the relevant principles of network flow and cost flow, many blogs written in gre ...

Posted by newzub on Sun, 22 May 2022 16:31:05 +0300

Real and complex matrices and their various operations implemented in C language

I. Introduction I recently worked as an intern in a company and spent three weeks working on an indoor positioning algorithm (rudimentary, not yet optimized) to realize the joint writing and debugging of matlab and C. The author believes that the difficulty lies in the various operations of the matrix. In C++ There is Eigen library available. E ...

Posted by manchuwok on Sun, 22 May 2022 14:49:52 +0300

Detailed explanation of monotonicity of decision-making

Necessary and sufficient conditions for monotonicity of decision making For two decision points, if at I, the large decision point is better than the small decision point, then at [i+1,n], the large decision point is better than the small decision point When proving, there is no need for mathematical proof, and it is enough to prove that the ...

Posted by Geof on Sun, 22 May 2022 09:04:14 +0300

Java sort Bubble

Bubble sorting 1. What is Bubble sorting? Bubble Sort is the most basic exchange sort. The reason why it is called bubble sorting is that each element can be sorted bit by bit according to its own size like a small bubble array Move to one side of the. Principle of bubble sorting: Only one number can be determined to be returned in each tr ...

Posted by iarp on Sun, 22 May 2022 02:48:53 +0300

Improvement of binary tree traversal algorithm (non recursive implementation)

Improvement of binary tree traversal algorithm The depth first traversal algorithms of binary tree are implemented by recursive functions, which is very inefficient. The reason is that the system calls a stack and does complex operations such as protecting the site and restoring the site, so that the traversal can be realized by very simple cod ...

Posted by Verrou on Sun, 22 May 2022 02:06:38 +0300