All problems can be found here: https://leetcode.com/problemset/
This is a repo of common Leetcode questions, I created it as I prefer writing code in an IDE, rather than something like Leetcode's online platform. A lot of these solutions may not be the most optimal, so don't take them as model answers. There are also unit tests around every problem, as I wanted to practice my TDD, which I think is something that is often overlooked especially for these types of interview questions.
I've included 'Solution' classes in each problem package where you can write your own solutions if you wish to do so (I assume if anyone comes across this, it's what you'd want to use this repo for). If you want to go a step further though, I'd recommend setting up something similar to this, so you can also TDD every problem.
I know most if most people had a choice they wouldn't want to solve these kind of questions in a language like Java, and would prefer something like Python or JavaScript which is understandable, but again this was mainly done to practice TDD.
Note that not all Leetcode Test Cases are included in the unit tests, I would encourage also writing your own unit tests around these solutions!
Some TDD videos:
You may need to mark the src
as the Sources Root folder - you can do this
by right-clicking it, selected 'Mark Directory as' -> Sources Root.
Similarly, you may need to do something similar with the test
directory, marking it
as the Test Sources Root.
- TwoSum
- Add Two Numbers
- Longest Substring Without Repeating Characters
- Median Of Two Sorted Arrays
- Longest Palindromic Substring
- Zigzag Conversion
- Reverse Integer
- String to Integer conversion (atoi)
- Palindrome Number
More to be added soon...