Skip to content

Carolzhangzz/DataStructure_Algorithm_HandBook_PreForLeetCode

Repository files navigation

This HandBook it currently developed by gitHub page.

Basic Language Features

右移和左移操作 js 语法

前端开发面试手写代码题

字符串解析 ConvertToTree 可取消的 promise

Basic Data Structure


LinkedList

206. Reverse Linked List

92. Reverse Linked List II

83. Remove Duplicates from Sorted List

19. Remove Nth Node From End of List

21. Merge Two Sorted Lists

160. Intersection of Two Linked Lists

2. Add Two Numbers

142. Linked List Cycle II


Hash Map

1160. Find Words That Can Be Formed by Characters

1189. Maximum Number of Balloons

1207. Unique Number of Occurrences

217. Contains Duplicate

20. Valid Parentheses


Search Algorithm

DFS(深度优先搜索)

BFS(广度优先搜索)

Binary tree

A binary tree is a simple directed graph where each node has a left node and a right node.

The main traversal methods of binary trees are BFS and DFS.

226. Invert Binary Tree

101. Symmetric Tree

104. Maximum Depth of Binary Tree

111. Minimum Depth of Binary Tree

222. Count Complete Tree Nodes

110. Balanced Binary Tree

257. Binary Tree Paths

404. Sum of Left Leaves

513. Find Bottom Left Tree Value

112. Path Sum

654. Maximum Binary Tree

617. Merge Two Binary Trees

235. Lowest Common Ancestor of a Binary Search Tree

108. Convert Sorted Array to Binary Search Tree

这个模块是一个小进阶的模块,涉及到了很多的递归,由于递归的思想和我们大脑的思考方法是相反的,但是回溯并不是一个很高效的算法,只适合解决一些数据规模比较小的场景。

77. Combinations

39. Combination Sum

40. Combination Sum II

216. Combination Sum III

93. Restore IP Addresses

78. Subsets

491. Non-decreasing Subsequences

46. Permutations

47. Permutations II

698. Partition to K Equal Sum Subsets

51. N-Queens


记忆化搜索

这个算法的核心就是在递归的基础上记录已经算过的状态,如果下次运算过相同的状态,直接返回已经算过的状态,避免重复运算。

优点:掌握了暴力搜索,比如回溯和递归的写法之后,入门会非常的简单,时间复杂度与常规的(自底向上)动态规划是一致的。

缺点:由于依然是使用递归,所以当数据规模大的时候会有比较大的栈消耗

总结:如果笔试的时候想不出自底向上的动态规划,那么直接使用记忆搜索就可以了

Tips for beginners:

Do not stay too long in one question ⏰.

When you are stuck, try to think for 7~10 minutes. If you still could not figure it out or have any ideas, you should see the answers.

Use tools to help you understand 📱.

Data structures can sometimes be difficult to grasp because it's hard to think through them using only your brain. Try drawing graphs and breaking down the steps.

Be patient and not limited to one solution 🤔.

Most questions should have various answers. Try to explore multiple solutions if you can. Sometimes, other answers will give you more insight. Remember, it's not about how many questions you've done; it's about whether you're familiar with the algorithms behind them.

Discuss code with others 👭👬.

Whether they fully understand it or not, discussing code with others can enhance your grasp of programming languages.