Leetcode problems and questions – the best 50
Whether web2 or web3, doing well on data structure, algorithm, and leetcode questions is important, not only for getting a job but developing a good foundation in computer science.
Many developers know they should be practicing leetcode (or alternatively, hackerrank, codecademy, or codewars), but if you haven’t started yet it can be very intimidating.
What Leetcode problems should you begin with and in what order should you go?
Getting over the psychological barrier of starting
Nothing is more demoralizing than opening up on of these websites, picking a random problem marked as easy, and then getting stuck. Now you have to expend three times the energy: finding the right problem, solving it, and not psyching yourself out wondering if you picked the wrong problem or are just not cut out for the test.
What we recommend doing is starting out with the leetcode questions and leetcode problems that are hilariously easy to do. No really, how’s this for a challenge?
https://leetcode.com/problems/add-two-integers/
func sum(num1 int, num2 int) int {
}
Easy coding problem to add two integers
Not too scary right?
Focusing on the core of the language
There are a lot of data structures and algorithms out there. There are trees, linked lists, heaps, queues, graphs, directed graphs, you name it! To avoid getting overwhelmed with choice, it’s best to focus on the data structures that are built into nearly all modern languages.
- arrays
- strings
- nested arrays (2d arrays)
- hash table
Most languages allow you to use these data structures without importing anything.
To use things like a Queue or a Heap, you have to import a library of some kind. As shiny and “new” as tech is, programming languages have been around for decades. They’ve evolved to make common actions easy. If a language requires more work to use, it will eventually fall out of favor all else being equal.
Mirroring a binary tree is not a common thing. But manipulating strings and arrays is very common, thus they are built into the language.
If you don’t know how to do these essential things in a language, you don’t know how to program in that language. Learning things like trees, graphs, and queues are not language specific. But if you can’t loop over an array in JavaScript, you can’t say you know JavaScript.
The list of problems we’ve compiled is designed to make sure you are comfortable with the essentials of the language. These problems will give you an excellent foundation to work off of for more advanced topics later.
Focus on logic and problem – solving first
The names of algorithms can be scary, usually they are the concatenation of rarely used European names with esoteric applications. Floyd-Warshall? Dijkstra’s algorithm? Fisher-Yates?
You can wait to learn those later.
But you absolutely must be able to do basic things that aren’t even “algorithm-y.”
For example, given a tic-tac-toe grid, can you tell if the game is over? You don’t need any fancy algorithms to accomplish this. If you struggle with this basic task, you will have a hard time with the more advanced algorithms listed above.
The problems we’ve listed here don’t need any special techniques to solve. Learn to apply basic logic and common sense solutions before you add more to your plate of more college-level kind of techniques.
Aren’t these too easy?
Maybe you aren’t the target audience for this, but you’d be surprised at the number of people who call themselves developers but can’t do fizz buzz. We’ve seen this first hand. When you apply to our program, you will promptly receive an email with a link to a coding test. One of them is fizz buzz. And the failure rate on that is high.
Maybe it’s nerves and not taking a coding test before. But if you’ve never practiced a coding test at least once, you are not doing yourself any favors.
Is this enough to pass coding interviews?
You might be able to get a job if you can solve all these problems! It would be a very entry level one at a company that isn’t very selective. But it’s possible nonetheless.
Don’t you have to pay to use these problems?
We’ve only included problems from the free version.
Copyright Notice
Due to plagiarism issues we’ve had with other software training programs, this work in its entirety is licensed under the Creative Commons NonCommercial License.
- https://leetcode.com/problems/convert-the-temperature/
- https://leetcode.com/problems/add-two-integers/
- https://leetcode.com/problems/smallest-even-multiple/
- https://leetcode.com/problems/final-value-of-variable-after-performing-operations/
- https://leetcode.com/problems/count-of-matches-in-tournament/
- https://leetcode.com/problems/number-of-common-factors/
- https://leetcode.com/problems/xor-operation-in-an-array/
- https://leetcode.com/problems/length-of-last-word/
- https://leetcode.com/problems/to-lower-case/
- https://leetcode.com/problems/to-lower-case/ (just do the opposite)
- https://leetcode.com/problems/reverse-string/ (don’t use two-pointers)
- https://leetcode.com/problems/valid-palindrome/
- https://leetcode.com/problems/count-vowel-substrings-of-a-string/ (don’t use hashmap)
- https://leetcode.com/problems/repeated-substring-pattern/
- https://leetcode.com/problems/defanging-an-ip-address/
- https://leetcode.com/problems/determine-color-of-a-chessboard-square/
- https://leetcode.com/problems/add-digits/
- https://leetcode.com/problems/jewels-and-stones/
- https://leetcode.com/problems/roman-to-integer/
- https://leetcode.com/problems/fizz-buzz/
- https://leetcode.com/problems/check-if-array-is-sorted-and-rotated/
- https://leetcode.com/problems/sort-an-array/ (ignore leetcode instructions, use built-in feature)
- https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/
- https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/
- https://leetcode.com/problems/find-first-palindromic-string-in-the-array/
- https://leetcode.com/problems/running-sum-of-1d-array/
- https://leetcode.com/problems/merge-two-sorted-lists/
- https://leetcode.com/problems/find-greatest-common-divisor-of-array/
- https://leetcode.com/problems/maximum-number-of-words-found-in-sentences/
- https://leetcode.com/problems/final-value-of-variable-after-performing-operations/
- https://leetcode.com/problems/shuffle-the-array/
- https://leetcode.com/problems/shuffle-string/
- https://leetcode.com/problems/cells-in-a-range-on-an-excel-sheet/
- https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits/
- https://leetcode.com/problems/decompress-run-length-encoded-list/
- https://leetcode.com/problems/richest-customer-wealth/
- https://leetcode.com/problems/flipping-an-image/
- https://leetcode.com/problems/lucky-numbers-in-a-matrix/
- https://leetcode.com/problems/shift-2d-grid/
- https://leetcode.com/problems/available-captures-for-rook/
- https://leetcode.com/problems/jewels-and-stones/
- https://leetcode.com/problems/decode-the-message/
- https://leetcode.com/problems/unique-morse-code-words/
- https://leetcode.com/problems/check-if-the-sentence-is-pangram/
- https://leetcode.com/problems/first-letter-to-appear-twice/
- https://leetcode.com/problems/sum-of-unique-elements/
- https://leetcode.com/problems/merge-similar-items/
- https://leetcode.com/problems/divide-array-into-equal-pairs/
- https://leetcode.com/problems/destination-city/
- https://leetcode.com/problems/number-of-good-pairs
Like what you see here? Check out our Free Solidity Course.
Originally Published Dec 8, 2022