Most of the problems are solved by using the Algo library. | |
Solutions to HackerRank problems. | |
Solutions to LeetCode problems. |
The problem solutions and implementations are entirely provided by Alex Prut. The code is not refactored, no coding style is followed, the only purpose of the written code is to pass all the platform tests of a given problem.
- Time Complexity
- Arrays
- Math
- Binary Search
- Strings
- Bit Manipulation
- Two Pointers
- Linked Lists
- Stacks And Queues
- Backtracking
- Hashing
- Heaps And Maps
- Tree Data Structure
- Dynamic Programming
- Greedy Algorithm
- Graph Data Structure And Algorithms
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Basic primer | LOOP_CMPL | 20 | Solution.txt |
Basic primer | NESTED_CMPL | 20 | Solution.txt |
Basic primer | NESTED_CMPL2 | 30 | Solution.txt |
Basic primer | CHOOSE4 | 50 | Solution.txt |
Math | WHILE_CMPL | 50 | Solution.txt |
Math | NESTED_CMPL3 | 80 | Solution.txt |
Math | LOOP_CMPL2 | 80 | Solution.txt |
Math | GCD_CMPL | 150 | Solution.txt |
Compare functions | CHOOSE1 | 50 | Solution.txt |
Compare functions | CHOOSE3 | 50 | Solution.txt |
Compare functions | CHOOSE2 | 80 | Solution.txt |
Function calling itself | REC_CMPL1 | 80 | Solution.txt |
Function calling itself | REC_CMPL2 | 80 | Solution.txt |
Function calling itself | REC_CMPL3 | 150 | Solution.txt |
Amortized complexity | AMORTIZED1 | 100 | Solution.txt |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Array math | Min Steps in Infinite Grid | 150 | Solution.java |
Array math | Add One To Number | 225 | Solution |
Array math | Max Sum Contiguous Subarray | 225 | Solution |
Array math | Maximum Absolute Difference | 250 | Solution |
Array math | Repeat and Missing Number Array | 350 | Solution |
Array math | Flip | 400 | Solution |
Simulation array | Max Non Negative SubArray | 150 | Solution.java |
Simulation array | Spiral Order Matrix II | 225 | Solution |
Simulation array | Pascal Triangle | 225 | Solution.java |
Simulation array | Kth Row of Pascal's Triangle | 225 | Solution |
Simulation array | Anti Diagonals | 225 | Solution |
Bucketing | Noble Integer | 200 | Solution.java |
Bucketing | Triplets with Sum between given range | 200 | Solution |
Bucketing | Largest Number | 225 | Solution.java |
Bucketing | Wave Array | 225 | Solution.java |
Bucketing | Hotel Bookings Possible | 225 | Solution |
Bucketing | Max Distance | 250 | Solution |
Bucketing | Maximum Unsorted Subarray | 250 | Solution |
Bucketing | Find Duplicate in Array | 450 | Solution.java |
Bucketing | Maximum Consecutive Gap | 450 | Solution |
Array | MAXSPPROD | 200 | Solution.java |
Arrangement | Largest Number | 225 | Solution.java |
Arrangement | Rotate Matrix | 300 | Solution |
Arrangement | Next Permutation | 300 | Solution |
Arrangement | Find Permutation | 300 | Solution |
Value ranges | Merge Intervals | 225 | Solution |
Value ranges | Merge Overlapping Intervals | 225 | Solution.java |
Bucketing or sorting | Hotel Bookings Possible | 225 | Solution |
Bucketing or sorting | Wave Array | 225 | Solution.java |
Bucketing or sorting | Largest Number | 225 | Solution.java |
Bucketing or sorting | Max Distance | 250 | Solution |
Bucketing or sorting | Maximum Unsorted Subarray | 250 | Solution |
Bucketing or sorting | Find Duplicate in Array | 450 | Solution.java |
Bucketing or sorting | Maximum Consecutive Gap | 450 | Solution |
Space recycle | Set Matrix Zeros | 300 | Solution.java |
Space recycle | First Missing Integer | 300 | Solution |
Missing / repeated number | First Missing Integer | 300 | Solution |
Missing / repeated number | Repeat and Missing Number Array | 350 | Solution |
Missing / repeated number | Find Duplicate in Array | 450 | Solution.java |
Missing / repeated number | N/3 Repeat Number | 600 | Solution |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Adhoc | Prime Sum | 150 | Solution.java |
Adhoc | Sum of pairwise Hamming Distance | 200 | Solution |
Adhoc | FizzBuzz | 200 | Solution.java |
Adhoc | Power Of Two Integers | 250 | Solution |
Base conversion | Excel Column Number | 175 | Solution.java |
Base conversion | Excel Column Title | 175 | Solution |
Digit op | Palindrome Integer | 200 | Solution.java |
Digit op | Reverse integer | 200 | Solution |
Number theory | Greatest Common Divisor | 200 | Solution.java |
Number theory | Trailing Zeros in Factorial | 250 | Solution |
Number theory | Sorted Permutation Rank | 250 | Solution |
Number theory | Largest Coprime Divisor | 250 | Solution |
Number theory | Sorted Permutation Rank with Repeats | 500 | Solution |
Array dp | Numbers of length N and value less than K | 200 | Solution |
Number encoding | Rearrange Array | 250 | Solution.java |
Combinatorics | City Tour | 300 | Solution |
Combinatorics | Grid Unique Paths | 375 | Solution.java |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Search answer | Matrix Median | 225 | Solution |
Search answer | Square Root of Integer | 275 | Solution.java |
Search answer | Painter's Partition Problem | 350 | Solution |
Search answer | Allocate Books | 350 | Solution |
Simple binary search | Matrix Search | 250 | Solution.java |
Simple binary search | Search for a Range | 250 | Solution.java |
Simple binary search | Sorted Insert Position | 250 | Solution.java |
Search step simulation | Implement Power Function | 275 | Solution |
Sort modification | Rotated Sorted Array Search | 325 | Solution.java |
Sort modification | Median of Array | 325 | Solution |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
String simulation | Palindrome String | 150 | Solution.java |
String simulation | Longest Common Prefix | 225 | Solution |
String simulation | Count And Say | 250 | Solution |
Programming | Amazing Subarrays | 150 | Solution.java |
Programming | Stringoholics | 300 | Solution |
String tricks | Minimum Characters required to make a String Palindromic | 200 | Solution |
String tricks | Longest Palindromic Substring | 500 | Solution |
String search | Minimum Characters required to make a String Palindromic | 200 | Solution |
String search | Implement StrStr | 225 | Solution.java |
String parsing | Minimum Characters required to make a String Palindromic | 200 | Solution |
String parsing | Compare Version Numbers | 225 | Solution |
String parsing | Atoi | 250 | Solution |
String parsing | Valid Number | 250 | Solution |
String parsing | Valid Ip Addresses | 250 | Solution |
Words | Length of Last Word | 225 | Solution.java |
Words | Reverse the String | 250 | Solution |
String math | Roman To Integer | 250 | Solution.java |
String math | Integer To Roman | 250 | Solution |
String math | Add Binary Strings | 300 | Solution |
String math | Power of 2 | 350 | Solution |
String math | Multiply Strings | 375 | Solution |
Pretty print | Justified Text | 300 | Solution |
Pretty print | Zigzag String | 300 | Solution.java |
Pretty print | Pretty Json | 400 | Solution |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Bucketing | Min XOR value | 200 | Solution.java |
Bit play | Number of 1 Bits | 200 | Solution.java |
Bit play | Reverse Bits | 225 | Solution.java |
Bit play | Divide Integers | 250 | Solution |
Bit play | Different Bits Sum Pairwise | 300 | Solution |
Bit array | Single Number | 275 | Solution.java |
Bit array | Single Number II | 275 | Solution |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Multiple arrays | Merge Two Sorted Lists II | 200 | Solution.java |
Multiple arrays | Intersection Of Sorted Arrays | 225 | Solution.java |
Two pointer | Minimize the absolute difference | 200 | Solution |
Sorting | 3 Sum | 225 | Solution |
Sorting | 3 Sum Zero | 225 | Solution |
Sorting | Counting Triangles | 225 | Solution |
Sorting | Diffk | 300 | Solution.java |
Inplace update | Remove Duplicates from Sorted Array | 250 | Solution.java |
Inplace update | Remove Duplicates from Sorted Array II | 250 | Solution |
Inplace update | Remove Element from Array | 250 | Solution |
Inplace update | Sort by Color | 325 | Solution.java |
Tricks | Max Continuous Series of 1s | 300 | Solution |
Tricks | Array 3 Pointers | 400 | Solution |
Tricks | Container With Most Water | 400 | Solution.java |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
List 2 pointer | Palindrome List | 200 | Solution |
List 2 pointer | Remove Duplicates from Sorted List | 300 | Solution.java |
List 2 pointer | Remove Duplicates from Sorted List II | 300 | Solution |
List 2 pointer | Merge Two Sorted Lists | 300 | Solution.java |
List 2 pointer | Remove Nth Node from List End | 350 | Solution |
List 2 pointer | Rotate List | 350 | Solution.java |
List 2 pointer | Reverse Link List II | 450 | Solution |
List 2 pointer | Reorder List | 600 | Solution |
Pointer move | K reverse linked list | 200 | Solution |
Pointer move | Swap List Nodes in pairs | 350 | Solution.java |
Pointer move | Reverse Link List II | 450 | Solution |
Pointer move | Reorder List | 600 | Solution |
List math | Add Two Numbers as Lists | 250 | Solution |
List math | List Cycle | 600 | Solution.java |
List sort | Partition List | 275 | Solution |
List sort | Insertion Sort List | 300 | Solution.java |
List sort | Sort List | 350 | Solution |
List trick | Reverse Link List II | 450 | Solution |
List trick | Reorder List | 600 | Solution |
List cycle | List Cycle | 600 | Solution.java |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Stack simple | Simplify Directory Path | 250 | Solution |
Stack simple | Redundant Braces | 300 | Solution.java |
Cleverstack | Nearest Smaller Element | 350 | Solution.java |
Cleverstack | Largest Rectangle in Histogram | 450 | Solution |
Cleverstack | Sliding Window Maximum | 450 | Solution |
Stack math | Evaluate Expression | 400 | Solution.java |
Stack math | Rain Water Trapped | 400 | Solution |
Multiple stack | Min Stack | 400 | Solution |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Subsets | Subset | 250 | Solution.java |
Subsets | Combinations | 300 | Solution |
Subsets | Combination Sum | 300 | Solution |
Subsets | Combination Sum II | 300 | Solution |
Subsets | Subsets II | 300 | Solution |
Bruteforce builder | Letter Phone | 250 | Solution |
Bruteforce builder | Palindrome Partitioning | 300 | Solution |
Bruteforce builder | Generate all Parentheses II | 350 | Solution.java |
Pruned builder | Palindrome Partitioning | 300 | Solution |
Bruteforce builder | Generate all Parentheses II | 350 | Solution.java |
Pruned builder | NQueens | 550 | Solution |
Pruned builder | Sudoku | 700 | Solution |
Permutations | Permutations | 350 | Solution.java |
Maths and backtracking | Gray Code | 350 | Solution |
Maths and backtracking | Kth Permutation Sequence | 350 | Solution |
Game solving | NQueens | 550 | Solution |
Game solving | Sudoku | 700 | Solution |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Hash search | Colorful Number | 150 | Solution |
Hash search | Largest Continuous Sequence Zero Sum | 200 | Solution |
Hash search | 2 Sum | 300 | Solution |
Hash search | 4 Sum | 325 | Solution |
Hash search | Valid Sudoku | 325 | Solution |
Hash search | Diffk II | 375 | Solution.java |
Key formation | Anagrams | 350 | Solution.java |
Key formation | Equal | 350 | Solution |
Key formation | Copy List | 450 | Solution |
Hashing two pointer | Longest Substring Without Repeat | 350 | Solution.java |
Hashing two pointer | Window String | 350 | Solution |
Maths and hashing | Fraction | 450 | Solution |
Maths and hashing | Points on the Straight Line | 450 | Solution |
Incremental hash | Substring Concatenation | 1000 | Solution |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Heap | N max pair combinations | 200 | Solution |
Heap | Magician and Chocolates | 250 | Solution.java |
Heap | Merge K Sorted Lists | 600 | Solution.java |
Math | Ways to form Max Heap | 200 | Solution |
Heapmap | Distinct Numbers in Window | 600 | Solution.java |
Heapmap | LRU Cache | 1000 | Solution |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Bucket 5 | Highest Product | 200 | Solution.java |
Bucket 6 | Bulbs | 200 | Solution.java |
Bucket 1 | Distribute Candy | 300 | Solution |
Bucket 1 | Assign Mice to Holes | 300 | Solution.java |
Bucket 4 | Seats | 300 | Solution |
Bucket 3 | Majority Element | 400 | Solution.java |
Bucket 2 | Gas Station | 700 | Solution |
Subdomain | Challenge | Score | Solution |
---|---|---|---|
Bfs | Smallest sequence with given Primes | 200 | Solution.java |
Bfs | Valid Path | 200 | Solution |
Bfs | Level Order | 300 | Solution.java |
Bfs | Smallest Multiple With 0 and 1 | 300 | Solution |
Graph connectivity | Commutable Islands | 200 | Solution |
Graph connectivity | Possibility of finishing all courses given pre-requisites | 200 | Solution |
Graph connectivity | Valid Path | 200 | Solution |
Graph connectivity | Black Shapes | 300 | Solution.java |
Graph connectivity | Capture Regions on Board | 500 | Solution |
Depth first search | Largest Distance between nodes of a Tree | 200 | Solution |
Graph traversal | Level Order | 300 | Solution.java |
Graph traversal | Stepping Numbers | 300 | Solution |
Graph traversal | Capture Regions on Board | 500 | Solution |
Graph traversal | Word Search Board | 500 | Solution |
Graph adhoc | Convert Sorted List to Binary Search Tree | 300 | Solution.java |
Shortest path | Sum Of Fibonacci Numbers | 300 | Solution.java |
Shortest path | Knight On Chess Board | 300 | Solution |
Shortest path | Word Ladder I | 600 | Solution |
Shortest path | Word Ladder II | 800 | Solution |
Graph hashing | Clone Graph | 500 | Solution |
Licensed under MIT.