Using LeetCode to Learn SQL For Data Analysis
Do you constantly hear people in tech throwing around the word “LeetCode”? Especially when talking about insane coding interviews?
I definitely did, and also freaked out when I realized that I needed to use it as practice for my data analyst coding interviews as well!
If you haven’t heard about LeetCode before, here’s a rundown:
LeetCode is a subscription-optional question bank website for coders. It has hundreds of questions that are helpful when preparing for technical interviews, especially for FAANG (Facebook, Amazon, Apple, Netflix, Google) and improving coding skills.
They have a lot of questions for free, but an account is required if you want to compile your data and see if it’s correct. In addition, LeetCode also has subscription options - monthly for $35 and yearly for $159, that grant access to premium features that include extra questions and the ability to see how frequent the questions are asked in interviews.
LeetCode is mainly used by software engineers, but they do have a section for SQL, which is what I will focus on.
So where do I start?
When on the LeetCode homepage, start by clicking on “Questions, Community & Contests”. This will take you to the questions page.
There you’ll see a whole list of questions. To filter to SQL questions, click the “Database” pill above the list.
Now we’ll take a look at the different columns in the table of questions.
Status: indicates whether or not the problem was submitted correctly
Title: The title of the question
Solution: a page with a check mark on it indicates that a detailed solution is available. (If this symbol is not available, don’t despair; there is a “Discussion” tab when you click into the question, and people usually post their code there)
Acceptance: This is the percentage of correct responses that were submitted for judging over the total number of responses submitted for judging
Difficulty: Difficulty of the question
Frequency: How frequently the question came up in coding interviews
When I first started using LeetCode, I’d order the questions based on “Difficulty” from easy to hard, but I soon realized that some of the Easy questions were actually quite challenging for me, while some of the medium and hard questions were a little more doable.
Therefore, I think sorting on “Acceptance” is a better indication of difficulty; the higher the acceptance percentage, the higher the likelihood that people got the question right on the first try.
LeetCode helped me fast track my learning because sometimes I’d come to a question, and have no idea where to start! I’d look in the Solution or Discussion tab, and see someone using a function that I had never encountered before. That would cause me to look it up on Mode or W3school, and add another function into my arsenal.
How can I use LeetCode with other Sites?
If you’re using Mode and LeetCode to study simultaneously, I’d say that the Difficulty on LeetCode corresponds pretty well to tutorial levels on Mode.
If using LeetCode with LinkedIn Learning, I’d say after completing SQL Essential Training, you’ll be pretty well-equipped to solve Easy and some Medium questions.
A few things to note
While LeetCode is a wonderful question bank, there are a few things to note:
- Not all questions are created equal. Some of them are very abstract questions that will probably never be asked on an interview or in a real work environment (I’m looking at you, random line and triangle questions). So if you’re asking yourself how relevant this question is, don’t be afraid to skip it.
- Some of the questions ask for a very specific output. At least in my experience, interview questions will not be so specific.
- Once you get comfortable with SQL, try alternating between medium, easy and hard questions! I noticed that after primarily solving medium and hard questions, I’d go back to the easy ones and make them so complicated! Alternating helped me refresh basic concepts while still challenging myself to learn more.
Remember, learning is a process. I remember when I did my first question, and it was labeled “easy” and had 95.8% acceptance rate. And I got it wrong. I felt so dumb and beat myself up over it, but that was me getting stuck in comparison and negativity. Allow yourself to feel your feelings, then take a deep breath, and try again.
After a while, you’ll look back and marvel how far you’ve come!
Please let me know how you’ve used LeetCode to learn SQL!