当前位置:网站首页>How to use leetcode

How to use leetcode

2022-06-26 08:39:00 yumuing

LeetCode Is a series of algorithm problems provided on , And have excellent online editing experience in multiple programming languages . On this basis ,LeetCode The description of various topics is simple and easy to understand , The question bank is updated very quickly , The most important thing is that its gold content is recognized by the public , Has a large user base , For each algorithm problem, we can basically find a better way to solve the problem . In particular , The platform focuses more on the training of algorithm ideas , Not taken ACM All inclusive mode , Instead, it provides a function that needs to be implemented , The definition of test cases and the calling of main methods will be provided by the system . Training is needed ACM Mode , You can try the question brushing mode of Niuke .

LeeCode Brush the question ideas

As a beginner , about LeetCode I dare not say how smart I am , Just a simple sharing from my experience in this period of time and the relevant knowledge I have learned .

Brush the order of questions

at present LeetCode The difficulty of the topic is classified as Simple 、 secondary 、 difficult . And the scale of the question bank has reached more than 2000 , It's still being updated , Such a huge question bank , Where to start . Every time I encounter various problems, I can't find a good solution . For example :

  • The direction of question brushing is not clear
  • The difficulty positioning of the question brushing is not clear
  • It will take time to find a good solution to the problem

First , Let's give you a brief introduction ,LeetCode Level of difficulty :

  • Simple
    This level of questions is designed to help you familiarize yourself with basic skills . Generally speaking , They have some simple and crude solutions , What we need to learn , Is to use these tips to improve their slightly rough problem-solving program . When we randomly open a simple problem of data structure or algorithm , Be able to list the best solutions and complete them in a few minutes

  • secondary
    The title of this level aims to train people's ability to see through problems , They are usually simple topics “ camouflage ” or “ change ”. The use of simple and crude solutions may result in a timeout . What we need to learn is to distinguish problems , And find the right way to solve the problem . Open a data structure randomly 、 Medium problem of algorithm , If we can find out what they cover up , And can write a near optimal answer in half an hour , Then we can appropriately challenge the difficult level topics .

  • difficult
    Usually , The difficulty ,45 Minutes is hardly enough time for us to write a complete answer . What we need to learn , Is to determine the correct direction of problem solving . For difficult questions, the best answer can be ignored , We start with a successful solution , You can also cancel the time for answering questions 、 Space restriction . After solving the problem , To really think about optimization .

For the direction of question brushing , See the background of different types of questions , Introduce the following :

Introduction to algorithm

If you are just getting started in the field of algorithms , If you want to brush the algorithm questions and practice your hands , It is suggested to start with a simple algorithm problem , also , For as long as possible ( a week 10 topic , There is plenty of time 30 topic ) Brush the same type of algorithm problems , Until the submission success rate reaches 80% And the code submission time should be more than 100% , After all , In terms of success rate, there may be some special test cases , Unable to reach 100% . For the choice of question brushing category , Each may have his own understanding , Here is my order of writing questions , Not necessarily for you :

Array -> Linked list -> Hashtable -> character string -> Stack and queue -> Trees -> Backtracking algorithm -> Greedy Algorithm -> Dynamic programming -> graph theory -> Advanced data structure

If , If possible , One and two strokes of the previously done topics , Finish the algorithm problems as quickly as possible . Exercise the acquisition and Realization of problem-solving ideas . If you have finished the above algorithm problems and can complete them at a faster speed , Then you can choose to participate in LeetCode Weekly race , Experience the feeling of competition .

Advanced algorithm

If you have been immersed in the algorithm field for many years , This tutorial is to teach you how to teach , Laugh at it. . however , Starting from my immature idea , At present, the direction of writing questions focuses on the related research of real questions , Facing employment , Brush the real algorithm problems of major companies , Face the competition , Brush the real competition questions of previous years .LeetCode There are also weekly races on the , It is recommended to go to the Internet version LeetCode Take part in the weekly competition , The domestic weekly competition is not particularly fierce , May not be able to meet the competitive pressure . Try to get LeetCode A few weeks before the race, it was the end of the victory .

How to brush questions

Brushing questions doesn't mean that it's OK to look at other people's ideas and even their code , What we need most is , For each algorithm problem solving ideas of understanding , It is recommended that you write corresponding notes after each algorithm problem , It can not only deepen the understanding of the current algorithm problem ideas , It is more convenient for later induction and summary of the same type of topics 、 Achieve mastery through a comprehensive .

LeetCode Platform question brushing strategy

  1. After filtering the algorithm problems to be trained , Start to enter the edit page , On the left is the problem description , On the right is the code editing area , The code editing area can change the language 、 The test case 、 Execute code, etc , There is also good support for intelligent code completion and syntax highlighting .
    [ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-IOSCmwfq-1641688244761)(/upload/2021/11/image-b974b921962d4d209d43daaf6d836ea7.png)]

  2. After understanding the requirements of the algorithm topic and editing the algorithm code , Execute the code first , The first submission can be carried out after the test cases with corresponding errors and problems can pass . Bear in mind , Don't read the comments and explanations , Solve the problem independently .

  3. If the answer is wrong after the first submission , You can click the answer error option on the left interface , Go to the corresponding page , You can know which test case failed , Copy the current use case , Return to the code editing interface , Rewrite the code , Fill in the test case column at the bottom of the right with the test case just copied , Execute the code again , After the execution is correct , Submit again .

  4. After successful code submission , You can know the quality problems of the current code , If not 100% , It shows that there is still room for optimization . if , We have been unable to get the idea of algorithm optimization , Then you can go to the comment area and solution area of the topic , So as to obtain the corresponding optimization and analysis ideas .

  5. Carefully analyze and compare the ideas of each answer , So as to learn how to solve problems , Take notes , Make it your own .

  6. If for LeetCode The built-in editor does not adapt , If you need to pull it locally , Just define... In the code main function , Construct an input use case , Finally, copy the code in the code editing area as a method function , And in main The function can be called .

Basically for LeetCode I have basically finished the introduction of the problems in question brushing . There are a few more points to be made , Cherish every submission ,( Executing code does not record ) The platform will record the submission details , And calculate the submission completion rate of each question , Last , There will be corresponding statistical data and skilled calculation in the personal data .

LeetCode Weekly strategy

about LeetCode In terms of weekly competitions , I haven't experienced it personally. I can only talk on paper , Select important official instructions for display , There may be errors and omissions , Look around .

Official statement

  • The ranking of the competition is calculated according to the score and completion time , Those with consistent scores will be ranked according to time . Each question will have a corresponding score , Often this score is evaluated according to the difficulty coefficient of the topic , The higher the difficulty, the greater the score .

  • The goal of the competition is to solve these problems in the shortest time , And ensure the minimum error rate . Every wrong submission will +5 minute Until you have a correct submission . The completion time is equal to the time you completed the current final topic plus the time of the overtime penalty . Be careful : The repeated submission of the passed questions will not have any impact on your competition results .

  • During the competition , There is no need to follow the sequence of questions given by the system . The strategy can be changed freely , After scanning all the questions , Start with the most accessible topic .

  • To ensure the fairness of the competition , Li Kou will be in the competition Hide some test cases . When the contestant fails to submit in the competition , Buckles will not show contestants hidden error cases .

  • Violations :

    • One person submits with multiple accounts ( Power button 「 The Chinese community LCCN」 and 「 American website LCUS」 The account number belongs to two accounts )

    • Submit the same code for multiple accounts ( Plagiarism )

    • Using improper means to influence others' competition

    • Post your answers in the discussion area before the end of the competition

  • Test cases are not comprehensive , It may cause some submissions that should not have passed to be displayed as “AC” . under these circumstances , The buckle will complement the test case and Rejudge all “AC” Submission of .

  • Effective submission

    • Hardcode Submit
      If contestants exist “Hardcode The test case ” Code for behavior “AC” I've got the title , The submission of the contestant will be determined as valid submission .
    • Pre calculation submission
      The pre calculation result means : The user has pre calculated some or all test case results , And add it directly to the submission code .
      Rules and scoring methods : If the submission code of the contestant has the behavior of pre calculating the results , We recommend that participants attach the code that generates the pre calculated results . For example, the contestant contains the code of pre calculated results “AC” I've got the title , The submission of the contestant will be determined as valid submission .

Related links

Recommend problem solving and analysis websites

Reference article

原网站

版权声明
本文为[yumuing]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170555425384.html