Skip to content

πŸ‘¨β€πŸ’» Learn common interview algorithms with step-by-step visuals πŸ–ΌοΈ and animations 🎞️

Notifications You must be signed in to change notification settings

kimtth/algorithm-interview-prep-with-visual

Repository files navigation

Python Algorithm Interview

Important

Translated version from the Korean version into English with D3.js visualization β€” master coding tests with 95 algorithm problems.

πŸš€ Quick Start

Open Visualization Index

πŸ‘‰ Open index.html to browse all problems with interactive visualizations.

β˜… Errata: https://www.onlybook.co.kr/entry/algorithm-interview-errata
β˜… Book Info: https://www.onlybook.co.kr/entry/algorithm-interview
β˜… YouTube: https://www.youtube.com/watch?v=fNyGHpSWhTA

Problem Solutions

# Title Difficulty Chapter Solution Code
1 Valid Palindrome β˜… Ch6. String Manipulation 1-1.py
1-2.py
1-3.py
1-4.c
2 Reverse String β˜… Ch6. String Manipulation 2-1.py
2-2.py
3 Reorder Data in Log Files β˜… Ch6. String Manipulation 3-1.py
4 Most Common Word β˜… Ch6. String Manipulation 4-1.py
5 Group Anagrams β˜…β˜… Ch6. String Manipulation 5-1.py
6 Longest Palindromic Substring β˜…β˜… Ch6. String Manipulation 6-1.py
7 Two Sum β˜… Ch7. Arrays 7-1.py
7-2.py
7-3.py
7-4.py
7-5.py
7-6.go
8 Trapping Rain Water β˜…β˜…β˜… Ch7. Arrays 8-1.py
8-2.py
9 3Sum β˜…β˜… Ch7. Arrays 9-1.py
9-2.py
10 Array Partition I β˜… Ch7. Arrays 10-1.py
10-2.py
10-3.py
11 Product of Array Except Self β˜…β˜… Ch7. Arrays 11-1.py
12 Best Time to Buy and Sell Stock β˜… Ch7. Arrays 12-1.py
12-2.py
13 Palindrome Linked List β˜… Ch8. Linked Lists 13-1.py
13-2.py
13-3.go
13-4.py
14 Merge Two Sorted Lists β˜… Ch8. Linked Lists 14-1.py
15 Reverse Linked List β˜… Ch8. Linked Lists 15-1.py
15-2.py
16 Add Two Numbers β˜…β˜… Ch8. Linked Lists 16-1.py
16-2.py
17 Swap Nodes in Pairs β˜…β˜… Ch8. Linked Lists 17-1.py
17-2.py
17-3.py
18 Odd Even Linked List β˜…β˜… Ch8. Linked Lists 18-1.py
19 Reverse Linked List II β˜…β˜… Ch8. Linked Lists 19-1.py
20 Valid Parentheses β˜… Ch9. Stack, Queue 20-1.py
21 Remove Duplicate Letters β˜…β˜…β˜… Ch9. Stack, Queue 21-1.py
21-2.py
22 Daily Temperatures β˜…β˜… Ch9. Stack, Queue 22-1.py
23 Implement Stack using Queues β˜… Ch9. Stack, Queue 23-1.py
24 Implement Queue using Stacks β˜… Ch9. Stack, Queue 24-1.py
25 Design Circular Queue β˜…β˜… Ch9. Stack, Queue 25-1.py
26 Design Circular Deque β˜…β˜… Ch10. Deque, Priority Queue 26-1.py
27 Merge k Sorted Lists β˜… Ch10. Deque, Priority Queue 27-1.py
28 Design HashMap β˜… Ch11. Hash Table 28-1.py
29 Jewels and Stones β˜… Ch11. Hash Table 29-1.py
29-2.py
29-3.py
29-4.py
30 Longest Substring Without Repeating Characters β˜…β˜… Ch11. Hash Table 30-1.py
31 Top K Frequent Elements β˜…β˜… Ch11. Hash Table 31-1.py
31-2.py
32 Number of Islands β˜…β˜… Ch12. Graph 32-1.py
33 Letter Combinations of a Phone Number β˜…β˜… Ch12. Graph 33-1.py
34 Permutations β˜…β˜… Ch12. Graph 34-1.py
34-2.py
35 Combinations β˜…β˜… Ch12. Graph 35-1.py
35-2.py
36 Combination Sum β˜…β˜… Ch12. Graph 36-1.py
37 Subsets β˜…β˜… Ch12. Graph 37-1.py
38 Reconstruct Itinerary β˜…β˜… Ch12. Graph 38-1.py
38-2.py
38-3.py
39 Course Schedule β˜…β˜… Ch12. Graph 39-1.py
39-2.py
40 Network Delay Time β˜…β˜… Ch13. Shortest Path 40-1.py
41 Cheapest Flights Within K Stops β˜…β˜… Ch13. Shortest Path 41-1.py
42 Maximum Depth of Binary Tree β˜… Ch14. Tree 42-1.py
43 Diameter of Binary Tree β˜… Ch14. Tree 43-1.py
44 Longest Univalue Path β˜… Ch14. Tree 44-1.py
45 Invert Binary Tree β˜… Ch14. Tree 45-1.py
45-2.py
45-3.py
45-4.py
46 Merge Two Binary Trees β˜… Ch14. Tree 46-1.py
47 Serialize and Deserialize Binary Tree β˜…β˜…β˜… Ch14. Tree 47-1.py
48 Balanced Binary Tree β˜… Ch14. Tree 48-1.py
49 Minimum Height Trees β˜…β˜… Ch14. Tree 49-1.py
50 Convert Sorted Array to Binary Search Tree β˜… Ch14. Tree 50-1.py
51 Binary Search Tree to Greater Sum Tree β˜…β˜… Ch14. Tree 51-1.py
52 Range Sum of BST β˜… Ch14. Tree 52-1.py
52-2.py
52-3.py
52-4.py
53 Minimum Distance Between BST Nodes β˜… Ch14. Tree 53-1.py
53-2.py
54 Construct Binary Tree from Preorder and Inorder Traversal β˜…β˜… Ch14. Tree 54-1.py
55 Kth Largest Element in an Array β˜…β˜… Ch15. Heap 55-1.py
55-2.py
55-3.py
55-4.py
56 Implement Trie (Prefix Tree) β˜…β˜… Ch16. Trie 56-1.py
57 Palindrome Pairs β˜…β˜…β˜… Ch16. Trie 57-1.py
57-2.py
58 Sort List β˜…β˜… Ch17. Sorting 58-1.py
58-3.py
59 Merge Intervals β˜…β˜… Ch17. Sorting 59-1.py
60 Insertion Sort List β˜…β˜… Ch17. Sorting 60-1.py
60-2.py
61 Largest Number β˜…β˜… Ch17. Sorting 61-1.py
62 Valid Anagram β˜… Ch17. Sorting 62-1.py
63 Sort Colors β˜…β˜… Ch17. Sorting 63-1.py
64 K Closest Points to Origin β˜…β˜… Ch17. Sorting 64-1.py
65 Binary Search β˜… Ch18. Binary Search 65-1.py
65-2.py
65-3.py
65-4.py
66 Search in Rotated Sorted Array β˜…β˜… Ch18. Binary Search 66-1.py
67 Intersection of Two Arrays β˜… Ch18. Binary Search 67-1.py
67-2.py
67-3.py
68 Two Sum II - Input Array Is Sorted β˜… Ch18. Binary Search 68-1.py
68-2.py
68-3.py
68-4.py
68-5.py
69 Search a 2D Matrix II β˜…β˜… Ch18. Binary Search 69-1.py
69-2.py
70 Single Number β˜… Ch19. Bit Manipulation 70-1.py
71 Hamming Distance β˜… Ch19. Bit Manipulation 71-1.py
72 Sum of Two Integers β˜…β˜…β˜… Ch19. Bit Manipulation 72-1.py
72-2.py
73 UTF-8 Validation β˜…β˜… Ch19. Bit Manipulation 73-1.py
74 Number of 1 Bits β˜… Ch19. Bit Manipulation 74-1.py
74-2.py
75 Sliding Window Maximum β˜…β˜…β˜… Ch20. Sliding Window 75-1.py
75-2.py
76 Minimum Window Substring β˜…β˜…β˜… Ch20. Sliding Window 76-1.py
76-2.py
76-3.py
77 Longest Repeating Character Replacement β˜…β˜… Ch20. Sliding Window 77-1.py
78 Best Time to Buy and Sell Stock II β˜… Ch21. Greedy Algorithm 78-1.py
78-2.py
79 Queue Reconstruction by Height β˜…β˜… Ch21. Greedy Algorithm 79-1.py
80 Task Scheduler β˜…β˜… Ch21. Greedy Algorithm 80-1.py
81 Gas Station β˜…β˜… Ch21. Greedy Algorithm 81-1.py
81-2.py
82 Assign Cookies β˜… Ch21. Greedy Algorithm 82-1.py
82-2.py
83 Majority Element β˜… Ch22. Divide and Conquer 83-1.py
83-2.py
83-3.py
83-4.py
84 Different Ways to Add Parentheses β˜…β˜… Ch22. Divide and Conquer 84-1.py
85 Fibonacci Number β˜… Ch23. Dynamic Programming 85-1.py
85-2.py
85-3.py
85-4.py
86 Maximum Subarray β˜… Ch23. Dynamic Programming 86-1.py
86-2.py
87 Climbing Stairs β˜… Ch23. Dynamic Programming 87-1.py
87-2.py
88 House Robber β˜… Ch23. Dynamic Programming 88-1.py
88-2.py

Additional Code (miscellaneous)

LeetCode Updates and More Efficient Solutions

  • Problem 7: Test cases were removed, resulting in different execution times. #62
  • Problem 25: For a more efficient solution, see #105.
  • Problem 33: For a more efficient solution, see #91.
  • Problem 35: For a more efficient solution, see #111.
  • Problem 36: For a more efficient solution, see #112.
  • Problem 41: Due to test case changes, the solution now times out. #104
  • Problem 47: Due to evaluation function changes, comment out the TreeNode declaration before running. #97
  • Problem 75: Additional test cases were added, solution no longer passes. For new solution, see #67.

About

πŸ‘¨β€πŸ’» Learn common interview algorithms with step-by-step visuals πŸ–ΌοΈ and animations 🎞️

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages