2

A cup of tea, a pack of cigarettes, and a day of brushing!

Many friends may struggle when they first start brushing LeetCode, often forgetting to brush, forgetting to brush again, entering an infinite loop, and the efficiency of brushing questions is very poor.

In fact, brushing questions should also pay attention to skills. If you master the correct brushing methods, you can get twice the result with half the effort~

Let me share some of my own brushing experience, I hope to inspire the theme owner!

There are three main techniques:

  1. Sort by topic.
  2. Difficulty is gradual.
  3. Make a summary.

1. Categorize the questions by topic

The questions on LeetCode are all classified. It is recommended to only brush the same type of questions in a time period, so that you can have a more comprehensive understanding of this type of data structure or algorithm, so as to deepen your understanding of this type of question. It's like practicing kung fu. In the early stage, some basic moves are familiar and mastered, and then these moves are colluded later, and they are mastered.

Personally, I am more accustomed to brushing questions according to categories, and I feel that the effect is OK.

I have sorted and classified the LeetCode topics, you can refer to the following:

Array operations

  • LeetCode54 Spiral Matrix
  • LeetCode75 Color Classification
  • LeetCode73 matrix zeroing
  • LeetCode76 Minimum Covering Substring
  • LeetCode384 Shuffle array
  • LeetCode581 Shortest unordered contiguous subarray
  • LeetCode945 Minimum increment to make an array unique

linked list operation

  • LeetCode19 delete the Nth node from the bottom of the linked list
  • LeetCode25 k sets of flipped linked lists
  • LeetCode61 rotating linked list
  • LeetCode138 Copy linked list with random pointer
  • LeetCode206 reverse linked list
  • LeetCode141 Ring List
  • LeetCode142 Circular Linked List II
  • LeetCode160 Intersecting linked list
  • LeetCode707 Designing Linked Lists

stack

  • LeetCode20 Valid Parentheses
  • LeetCode32 longest valid parenthesis
  • LeetCode155 minimal stack
  • LeetCode224 Basic Calculator
  • LeetCode232 implements queue with stack
  • LeetCode316 remove duplicate letters

heap

  • LeetCode215 Kth largest element in array
  • LeetCode347 Top K high frequency elements

tree traversal

  • Inorder traversal of LeetCode94 binary tree
  • LeetCode102 Hierarchical Traversal of Binary Trees
  • LeetCode110 Balanced Binary Tree
  • LeetCode144 Preorder Traversal of Binary Tree
  • LeetCode145 Postorder Traversal of Binary Tree

Binary Search Tree Phase

  • LeetCode98 Verify Binary Search Tree
  • LeetCode450 delete node in binary search tree
  • LeetCode701 Insertion in Binary Search Tree

recursive

  • LeetCode21 merge two ordered linked lists
  • LeetCode101 Symmetric Binary Tree
  • LeetCode104 Maximum depth of binary tree
  • LeetCode226 flip binary tree
  • LeetCode236 Last Common Ancestor of Binary Trees

Dual pointer/sliding window

  • LeetCode3 longest substring without repeating characters
  • LeetCode11 The container that holds the most water
  • LeetCode15 Sum of Three Numbers
  • LeetCode16 Sum of the closest three numbers
  • LeetCode26 remove duplicates in sorted array
  • LeetCode42 catch rain
  • LeetCode121 The Best Time to Buy and Sell Stocks
  • LeetCode209 Subarray with the smallest length

slow pointer traversal

  • LeetCode141 Ring List
  • LeetCode202 Happy Numbers
  • Intermediate node of LeetCode876 linked list

Dynamic Programming

  • LeetCode5 longest palindrome substring
  • LeetCode53 Maximum Suborder Sum
  • LeetCode62 different paths
  • LeetCode64 minimum path and
  • LeetCode70 Climbing Stairs
  • LeetCode118 Yanghui Triangle
  • LeetCode300 longest ascending subsequence
  • LeetCode1143 Longest Common Subsequence

Backtracking

  • LeetCode10 regular expression matching
  • LeetCode22 bracket generation
  • LeetCode40 Combination Sum 2
  • LeetCode46 full array

greedy algorithm

  • LeetCode 11. The container that holds the most water
  • LeetCode 406. Rebuild queues based on height
  • LeetCode 55. Jumping Game
  • LeetCode 122. The Best Time to Buy and Sell Stocks II
  • LeetCode 309. The Best Time to Buy and Sell Stocks with Freezing Period
  • LeetCode 714. The Best Time to Buy and Sell Stocks Including Fees

and set

  • Number of islands in LeetCode200
  • LeetCode547 Number of Provinces

-bit operation

  • LeetCode52 N Queen II
  • LeetCode338 bit count
  • LeetCode191 Number of 1s
  • LeetCode231 Power of 2

2. The difficulty should be gradual

This is for beginners, remember to do hard-level questions as soon as you get up, it will make you doubt your life. .

The right way to do it is to work gradually, from easy to medium to hard levels. However, the inspection algorithms of large domestic factories are generally of medium difficulty, and those with difficulty levels should be rarely inspected.

3. Make a good summary

more summaries! Do more summaries! Do more summaries!

It is very important to do a good summary , especially for problems with no ideas, after reading the solutions of other bigwigs, think more about which problems are similar solutions, the key problem solving steps of this kind of problems, write down your own understanding, It is convenient for you to check later.

Although it may take you half an hour or more to summarize, if you don't summarize, the next time you encounter this problem, you may spend more time thinking and answering.


程序员大彬
468 声望489 粉丝

非科班转码,个人网站:topjavaer.cn