#### Category : Interview

Introduction to Binary Tree Basic structure: function TreeNode(x) { this.val = x; this.left = null; this.right = null; } Definition of traversal of binary tree’s pre-order, mid-order and post-order; Preorder traversal: for any subtree, first access heel, then traverse its left subtree, and finally traverse its right subtree; Mid-order traversal: for any subtree, first traverse ..

subject Two stacks are used to implement a queue to complete Push and Pop operations of the queue. The elements in the queue are of type int. Basic idea Stack 1: For in-queue storage Stack 2: When leaving the queue, the data of stack 1 are sequentially pushed out of the stack and merged into ..

subject Moving the first few elements of an array to the end of the array is called the rotation of the array. Enter a rotation of a non-subtractive array and output the smallest element of the rotated array. For example, array {3,4,5,1,2} is a rotation of {1,2,3,4,5}, and the minimum value of the array is ..

subject Title descriptionEveryone knows the Fibonacci sequence. Now you are required to enter an integer n. Please output the n-th term of the Fibonacci sequence (starting from 0, the 0-th term is 0). Basic idea This problem is actually treated as a counterexample of recursion in the sword-like offer. The essence of recursion is that ..

subject Enter an integer and output the number of 1s in the binary representation of the number. Where negative numbers are represented by complements. Analysis This is a question of examining binary system Binary or Operator (OR): The sign is |, indicating that if both binary bits are 0, the result is 0, otherwise it ..

Topic 1 Integer Power of Numeric Value Given a double type floating point number base and an int type integer exponent. Find the exponent of base. Train of thought This problem is logically simple, but it is easy to make mistakes. The key is to consider all aspects and all situations. When exponent is positive, ..

subject Enter a linked list and output the k nodes from the bottom of the linked list. Train of thought Simple idea: loop to the end of linked list to find length, loop twice to find length-k node. Optimization: set two nodes with a distance of k nodes. when the front node reaches the end ..

subject To define the data structure of the stack, please implement a min function (time complexity should be O(1)) in this type that can obtain the minimum elements contained in the stack. Train of thought 1. Define two stacks, one stack is used to store data and the other stack is used to store the ..

1. Topic Let’s talk about the understanding of variable promotion. Explain several different usage scenarios for this Create 10 A tags and click to pop up the corresponding serial numbers How to Understand Scope Application of Closure in Practical Development Manually implement call apply bind 2. Knowledge points 2.1 Execution Context Scope: a script or ..