March 2020 do title record

[Updated from time to time, to catch the paper, catch project, from January to February recorded still do question finishing, self-training]

Reverse list

Links: https://leetcode-cn.com/problems/reverse-linked-list/
class name:
inspection point: the list, iteration, recursion
problem-solving process:
power button, March 1 daily problem, problem solution links:
HTTPS: / /leetcode-cn.com/problems/reverse-linked-list/solution/di-2ci-da-qia-lian-biao-fan-zhuan-di-gui-by-wu-xi-/
is the record of the current node previous position, change the position of the current node pointed to the previous access node, the first node pointing to null, and finally became the root node. In line with recursive thinking. Recursive and iterative must take into account how the node position before recording a traversal, temporary iteration variable holds, but recursion is a parameter stored in the parameter list.

All nodes of the binary tree from the point K

Links: https://leetcode-cn.com/problems/all-nodes-distance-k-in-binary-tree/
class name:
inspection point: tree, recursion, deep search, backtracking
problem-solving process:
beginning only consider node node desires equal values of left and right subtrees, not taking into account the direction of the parent node of the current node. Later his son to save the current node with the hash table, then BFS father of the current node, left and right node direction, due to the need backtracking search, to avoid repeating the direction walked away, walked with a save node set, each recording recursive walking path length, until the length of the subject claim take an equal value and the current value requirements of the subject node, then the current iteration is the root node of the child nodes that satisfy the requirements. Toss fast 2h, or finally came out whole. While touching and memory consumption by.

Stack achieved with queue

Links: https://leetcode-cn.com/problems/implement-stack-using-queues/
class name:
inspection point: queue, stack
the problem solving process:
Consider stack is characterized by last-out, the characteristics of the queue is FIFO out. Therefore, by selecting two queues to simulate the behavior of the stack.
Always maintain a queue is empty, the empty queue as a transit area in another queue simulation data stack behavior (do not know what words to describe).
1, push: which queue is empty, then inserted into another queue;
2, POP: A data queue is non-empty one by one into empty queue B is taken out, when the last remaining non-empty queue element, is the top element, due to the need
to remove this value, the last non-empty queue element a is not placed in the original B-empty queue;
. 3, Top: and behaves like pop, as the only different point is a stack value whichever element only, without removing, and therefore choose to use a temporary variable to
save the value of each movement;
. 4, empty: determining whether the queue is empty to two.
Buckle force on March 1 daily problem, problem solution links:
https://leetcode-cn.com/problems/implement-stack-using-queues/solution/di-1tian-da-qia-by-wu-xi-4/

Another tree subtree

Links: https://leetcode-cn.com/problems/subtree-of-another-tree/
class name:
inspection point: the tree, the recursive
problem solving process: much still to do problems related to tree.
A tree, the tree B, B is determined whether the sub-tree of the tree A, where subtree tree node from a node A means is formed at the disconnected position of the tree and the number of the same as B. A step by step analysis of traversing each node of the tree A, assumed that each node as the root node, whether left or right subtree of this node determines subtree formed in the same tree B, the determination process is an independent iteration, this node is to compare the left and right sub-tree child node tree nodes B corresponding to the root node.

Binary tree list

Links: https://leetcode-cn.com/problems/linked-list-in-binary-tree/
class name:
inspection point: the tree, the recursive
problem solving process:
and "sub-tree to another tree," almost a problem-solving as a mold. The only thing to note is that when B is null tree is determined, and the tree to be determined A is not empty, to be true.

Guess you like

Origin www.cnblogs.com/ranh941/p/12398987.html
Recommended