Problems from https://www.dailycodingproblem.com/
Related repositories:
Other sites that I recommend: LintCode, NeetCode 150, AlgoMonster and Tech Interview Handbook.
Use the JVM flag -enableassertions
or -ea
to run Java files. The VSCode config in this repository already includes this flag when running files through F5 key or run button.
Java 11+ -> java -ea File.java
Java < 11 -> javac File.java && java -ea File
Array & Sorting
Segregate array RGB
HARD https://docs.google.com/document/d/1UUKcalnbwuwCqqX3-BMPnOJltlu3chzi3cz-hYalPa0/edit
Array & Mergesort & Fenwick Tree
Count Inversions
MEDIUM https://docs.google.com/document/d/1zkiWltcwUgtsQmwnBXZRPmm7a67jULKET_AlNBrumww/edit
Array & Set
Two numbers that add up to k
EASY https://docs.google.com/document/d/18kkJ9b8gRS0KlhaDCZ2CnqfTLUHRo_h7YxXpZKEmpA8/edit
Array & Dynamic Programming
Subset sum
HARD https://docs.google.com/document/d/13RvqTjxhWbSaH4M7DbeAG2HfTVEmxk5mH4N5CdfjR28/edit
Best Time to Buy and Sell Stock
EASY https://docs.google.com/document/d/1Z5jU_RQZmb1id3dPQA2yAMscZ8r2K69pA2eL-rNyUkQ/edit
Maximum Sum of any Contiguous Subarray
https://leetcode.com/problems/maximum-subarray/
EASY https://docs.google.com/document/d/1BNwJsRQlnmAtG5YGPj2fjjf1kVfzWrlMFwA4W0-LJ6g/edit
Array & Bit Manipulation
Single Number II
HARD https://docs.google.com/document/d/18kkJ9b8gRS0KlhaDCZ2CnqfTLUHRo_h7YxXpZKEmpA8/edit
https://leetcode.com/problems/single-number-ii/
Tree
Unival tree
EASY https://docs.google.com/document/d/1HmzZUOJF1MjvfbyjG7x9LLyUjhpZGtvkK_c__LLRjcM/edit
Locking binary tree
MEDIUM https://docs.google.com/document/d/1mkl0dP3R_ZOiUBm7MSm_21XhXfdeMROYiAiE9ufrcaE/edit
Construct Binary Tree from Preorder and Inorder Traversal
https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
MEDIUM https://docs.google.com/document/d/1ISaHWQZT7peTJrYZNonTrZ8eA75NJM9AMODu38yNBGA/edit
Arithmetic Expression as Binary Tree
EASY https://docs.google.com/document/d/1JVoj4xxl1cEI-uoYRUg1MLT57xik1ids5CsqyZZP-rE/edit
Binary Search Tree
Find Second Largest Node in BST
MEDIUM https://docs.google.com/document/d/1DGQbR1uTFzi1EwMvHNH2dsVmh2aoNOsxBxbrGkGkLIc/edit
Design Patterns
Java Visitor Pattern in Trees
https://www.hackerrank.com/challenges/java-vistor-pattern/problem
MEDIUM
Design & Doubly Linked List & Hash Table
LRU Cache
https://leetcode.com/problems/lru-cache/
HARD https://docs.google.com/document/d/1A3Y1KeZoSXaeSkvmaV5sOFFEfETz9NrB1-KTyo5nS1Q/edit
Design & Linked List & XOR
XOR Linked List
HARD https://docs.google.com/document/d/1iXh7V-6894dLyuloXUkVSt9EZVhHxxi-YI8JblrCmQc/edit
Recursion & Backtracking & Bit Manipulation
Generate Power Set
https://docs.google.com/document/d/1Q7xzRBweAu35DduNOhRiVf2KhpYb_a-Sk9DhQlEpqtc/edit
Recursion & Dynamic Programming & Greedy
Largest sum of non-adjacent numbers
HARD https://docs.google.com/document/d/1_wOPxfxUyN17pb10uRxDGy4k-o6HNLF3MsJSssLWwQA/edit
Decode Ways
MEDIUM https://docs.google.com/document/d/1FZW_3eeApIw1nm5P0rUpk4roeEZodeZdS-_K6tyGK7Y/edit
Threading & Heap
Job scheduler
MEDIUM https://docs.google.com/document/d/1Iey0V1qMA4oYoEbeW57FWhW-qvIqwQyZker-Kop3eRA/edit
Math & Random numbers
Phi value using Monte Carlo
MEDIUM
Shuffle Deck of Cards
MEDIUM https://docs.google.com/document/d/1WC4esJyT8gIIcqusoz8EnajaLMgqMurXIIzg9fJ7hMk/edit
Stream processing & Sorting & Heap & Two Pointers
Compute running median of a sequence of numbers
HARD https://docs.google.com/document/d/1Eqpg00jqSXdkirde_syFUKWE_0Lwg29j-3e7aWCMc_w/edit
Stream processing & Probability
Random from infinite stream with uniform probability
MEDIUM https://docs.google.com/document/d/1nztRYdD4VZL7rDiGUmII5yVqO_ILPqZ7wgUU-XSCY40/edit
String
Next Closest Time (I found a time and space O(1) solution)
MEDIUM https://docs.google.com/document/d/1ZNtArt-tqToZBiZ_C54ou4I73DTpk2kIEt8W7pmBzlo/edit
Justify Text
MEDIUM https://docs.google.com/document/d/14fN3Iz0xIEodIUXE5hn0zORIv-cIt9u9Zn7zigZEcEo/edit
Run-length encoding
EASY https://docs.google.com/document/d/1MVKaU14umdU9zVVRpdPJ2h_2vb4gI-AQOCRpyeMEtu8/edit
String & Dynamic Programming
Edit Distance
HARD https://docs.google.com/document/d/1GTaBwvNs5A7-PHP0huaurgm6UZLj87I1UvbdoiLhpMc/edit
Palindrome with Fewest Number of Insertions
MEDIUM https://docs.google.com/document/d/1XMTrT6Cay7vy-nId0BOBL3dBEqPdUjCMexbtUcx1zEs/edit
Longest Palindromic Substring
https://www.lintcode.com/problem/200/description
MEDIUM https://docs.google.com/document/d/1SbD0UvXt8lMX6ev4vrAPasQauNED6WXvssWqXI7VZ3o/edit
String & Trie & Dynamic Programming & Hash Table & Memoization
Word break
MEDIUM https://docs.google.com/document/d/1I1RDKSbtRYF5oPGs7aUPHm2f-GsgW45fqforcoTFnZo/edit
Design & Stack & Queue
Implement Queue using Stacks
https://leetcode.com/problems/implement-queue-using-stacks/
MEDIUM https://docs.google.com/document/d/1AjjQdxDyJM_W7Mjxg2UKFht5X2QF7Ciq1VUuO13C6Ys/edit
Design & Stack
LogRecorder
EASY https://docs.google.com/document/d/16QXfXUHrdgyczp-OiATvEaR82WOeDNEWbx7UnQ4k7FE/edit
MaxStack
EASY https://docs.google.com/document/d/1fcbNkXjq9feiURiK6__T32s_sKehI9y2NMMPXeq6_T8/edit
Stack
Valid Parentheses
EASY https://docs.google.com/document/d/1mnGKhudWq6PZLBPnbpesIpA1rnFVhe5bXsUv3AKHbuI/edit
Matrix & Recursion/Backtracking
N Queens Num of Possible Rearrengements
HARD https://docs.google.com/document/d/1xSjmfY4_Orr6xkmOOtW5TISRy7A0sETfb3qxaUAwv7g/edit
Matrix & Recursion & Dynamic Programming
Paint houses with different colors
MEDIUM https://docs.google.com/document/d/1quFNUoYf89u1X790EHDwQl2nCetRfoIVdKNzd7p-22o/edit
Shortest Possible Path in a Maze
EASY https://docs.google.com/document/d/1Eg5_gfQ_WA31NcaVTvbjtg2RnUiCxajltqV4hUEh6IQ/edit
Graph & DFS
Reconstruct Itinerary
HARD https://docs.google.com/document/d/1LxFSfPXpHg6mQQlb1vn9B7tmpw3bQlvaP1kNDz9nwkk/edit
Graph & DFS & Bellman Ford
Find Arbitrage Opportunity
HARD https://docs.google.com/document/d/1WcqP_Z0ckTYpANGOqVh97vgaN860DhDIz9l9HoJ-5PE/edit