Collection of coding questions taken from Cracking the coding interview book, LeetCode, HackerRank, CodeWars, CodingBat.com and other sources. All questions are solved using Java language. Directories are named after the source of the question so all leetcode questions I have done can be found in said directory. Questions are also organized by topics
Daily updates will be added as I continue to solve more from leetcode and HackerRank. Complex questions include comments to help understand approach. I try to come up or find the easiest solutions to problems to ensure the comprehension of the code is clear. I like to believe that if a question is giving you a rough time, it's ok to see a good solution and learn from it rather than making it more complex.
- Primitive Arrays
- 2-D Arrays
- Lists (e.g. Linked Lists, Array Lists)
- Stacks
- Queues, Deque, Priority Queues
- Maps (e.g. Sets, Hash Maps)
- Binary Trees
- If the given array is sorted consider using,
- Binary Search
- Two Pointers
- If asked to give all leetCode.backtracking.permutations/leetCode.backtracking.subsets for a given set of data,
- Backtracking
- Sorting given data can help reduce extra work
- If given a Tree or Graph,
- DFS (Depth First Search)
- BFS (Breath First Search)
- If given a linked list,
- Two Pointers
- If recursion is not allowed, a stack is equivalent to the recursion stack used by the compiler
- If you're not allowed to use other data structures and must solve in-place consider,
- swapping values
- store one or more different values in the same pointer
- If asked for maximum/minimum subarray/subsest/options,
- Dynamic Programming
- If asked for top/least K items,
- Heaps (e.g. Priority Queues)
- If asked for common strings, string prefixes, etc.
- Map
- Trie
- If asked for prefix sums
- Binary Indexed Trees
- If multiplication, addition, division, subtraction are not allowed
- Bitwise operators
Feel free to make pull request's to add comments or suggest improvements on the code currently available. Also, check out my Algorithms and data-structures repo for help on implementing specific data structures; more will be added as I continue to study topics.