0% found this document useful (0 votes)
4 views

03+Online+Judge+ +LeetCode+ +Proofread

The document provides an overview of the LeetCode online judge, which is a platform for evaluating programming solutions through various coding problems. It outlines the structure of problems, difficulty levels, and tips for successful submissions, including the importance of adhering to guidelines and the availability of solutions. Additionally, it highlights the benefits of LeetCode Premium, particularly for accessing company-specific problems frequently encountered in interviews.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

03+Online+Judge+ +LeetCode+ +Proofread

The document provides an overview of the LeetCode online judge, which is a platform for evaluating programming solutions through various coding problems. It outlines the structure of problems, difficulty levels, and tips for successful submissions, including the importance of adhering to guidelines and the availability of solutions. Additionally, it highlights the benefits of LeetCode Premium, particularly for accessing company-specific problems frequently encountered in interviews.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Cracking Coding Interviews

Online Judge - LeetCode

Mostafa S. Ibrahim
Teaching, Training and Coaching since more than a decade!

Artificial Intelligence & Computer Vision Researcher


PhD from Simon Fraser University - Canada
Bachelor / Msc from Cairo University - Egypt
Ex-(Software Engineer / ICPC World Finalist)
Online Judge (OJ)
● A site/app that is used to evaluate a programming solution
○ Task: read 2 numbers and print their sum
○ Behind the scenes: some files with test cases
■ Input file: 10 17 Output file: 27
○ Write your code in your chosen language
■ Upload and submit
○ Behind the scenes: automatic compilation, and running your code with the input files
■ Comparing the output file for each test case
■ Check if the solution takes a lot of time or memory
■ Verifies correctness, by checking your outputs against the expected outputs
● Tip: you must strictly follow the OJ guidelines
○ Pay special attention to the output format
○ Ensure the accuracy of the given class or function name
Online judges
● Online judges started with competitive programming
● There are many judges out there with thousands of problems
○ Uva, codeforces, topcoder, hackerank, SPOJ, Euler Project
○ Typically you read from a file or a console and print to the console
● LeetCode OJ
○ The destination for anyone targeting interviews
○ Interview problems are generally much shorter and simpler than competition problems
○ LeetCode has a wide collection of problems that appear frequently in interviews
○ In LeetCode, you upload a specific class/function name.
○ You don't include the main() function (like in C++ or Java), or try to read in from the user
○ It also has other types of questions such as Database, Shell, and Concurrency
Visit: https://leetcode.com
● Click The Problems tab
Problems list
3 Difficulty Levels
● Easy (level 1-3)
○ Basic problems to warm up (e.g. search for a number in a sorted array)
○ Appear in interviews as a warm-up question (you should these quickly)
○ A good tool to speed up coding skills
● Medium (level 4-7)
○ Makes up 85% of the coding interviews. Typically several solutions are possible.
● Hard (level 8-10)
○ Some never appear in interviews, as the text is very long, or the solutions are either too
specific, or mere 'hit-or-miss' problems
○ The best hard ones require several observations and good coding skills
○ Compared to other companies, more likely to appear as part of Pinterest, Snapchat, Airbnb, or
Twitter interviews.
● Label Accuracy: You will encounter some problems with inaccurate labels
Filtering Topics
● From tags: you can choose to concentrate exclusively on topics of interest
● In the 'Difficulty' tab, you can sort them from easy to medium to hard
● Notice that Problem #314 is only available for premium subscription
Solutions & Frequency tabs
● Solutions
○ Some problems have text solutions
○ Some problems have video + text solutions
○ There are also problems without solutions!
○ There are free and 'paid content' solutions
■ There are many solutions on GeeksforGeeks
■ There are also many YouTube videos
● Frequency
○ Subscriber only
○ You can get information on general frequency
○ And even frequency for a specific company
Open a problem
● 4 tabs
● The Discussions tab is a great one: you can check if other people have
alternative or more succinct solutions. Occasionally, an idea/code in this tab is
superior to that of the editorial
○ Submissions with many languages. Search for your preferred language
● Avoid problems that are seriously hated by others
Problem Solving part
● From the menu, select your language
● It generates the function name
● Fill in this code
● In the submission, never include the
main function
● You must use the requested class
name
Problem Solving part: languages
Problem Solving part: C++ Final code
● No main()
● No printing to the screen
● You don’t even need to use #includes
● For me
○ I code locally
○ Then rename the main to main1
Test and Submit buttons
● Before submitting your code, you can run some of the test cases
○ Copy-paste from the problem.
○ Strictly follow the available style
○ Sometimes it is hard to understand the test case structure
Result
● If 'Failed', you can
check out the
relevant test cases
● If successful, there
is a time and
memory comparison
with other solutions
○ If your code already
has good
complexity, don't
waste time here
Premium Feature
● The best part about LeetCode Premium is the ability to know
company-specific frequently occurring problems.
○ Below for Facebook: https://leetcode.com/company/facebook/
■ There are 645+ problems
○ In this course, I focus on the most frequent problems
“Acquire knowledge and impart it to the people.”

“Seek knowledge from the Cradle to the Grave.”

You might also like