Skip to content

kimtth/neet-code-top-150-python-visual

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NeetCode 150+ Algorithm Solutions πŸš€

Overview

This repository contains 193 Python 🐍 and 178 Java β˜• solutions to LeetCode problems, with a focus on the NeetCode 150 🌊 - a curated list of essential coding interview questions! πŸ’»

Legend

Symbol Meaning
🐍 Python solution available
β˜• Java solution available
🌊 Part of NeetCode 150 list
πŸ“Š Interactive visualization available

Quick Stats

Category Count
Python Solutions 🐍 193
Java Solutions β˜• 178
NeetCode 150 🌊 150
Visualizations πŸ“Š 193

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

main

Problem Categories πŸ“‹

Array & Hashing πŸ“Š

# Problem 🐍 β˜• 🌊 πŸ“Š
1 Two Sum βœ… ❌ βœ… Visual
36 Valid Sudoku βœ… βœ… βœ… Visual
49 Group Anagrams βœ… βœ… βœ… Visual
88 Merge Sorted Array βœ… βœ… ❌ Visual
118 Pascal's Triangle βœ… βœ… ❌ Visual
128 Longest Consecutive Sequence βœ… βœ… βœ… Visual
169 Majority Element βœ… βœ… ❌ Visual
202 Happy Number βœ… βœ… βœ… Visual
217 Contains Duplicate βœ… βœ… βœ… Visual
238 Product of Array Except Self βœ… βœ… βœ… Visual
242 Valid Anagram βœ… βœ… βœ… Visual
271 Encode and Decode Strings βœ… βœ… βœ… Visual
289 Game of Life βœ… βœ… ❌ Visual
347 Top K Frequent Elements βœ… βœ… βœ… Visual
380 Insert Delete GetRandom O(1) βœ… βœ… ❌ Visual
412 Fizz Buzz βœ… βœ… ❌ Visual
953 Verifying an Alien Dictionary βœ… βœ… βœ… Visual
1086 High Five βœ… βœ… ❌ Visual

Two Pointers πŸ‘‰πŸ‘‰

# Problem 🐍 β˜• 🌊 πŸ“Š
11 Container With Most Water βœ… βœ… βœ… Visual
15 3Sum βœ… βœ… βœ… Visual
42 Trapping Rain Water βœ… βœ… βœ… Visual
125 Valid Palindrome βœ… βœ… βœ… Visual
167 Two Sum II βœ… βœ… βœ… Visual

Sliding Window πŸͺŸ

# Problem 🐍 β˜• 🌊 πŸ“Š
3 Longest Substring Without Repeating Characters βœ… βœ… βœ… Visual
76 Minimum Window Substring βœ… βœ… βœ… Visual
121 Best Time to Buy and Sell Stock βœ… βœ… βœ… Visual
239 Sliding Window Maximum βœ… βœ… βœ… Visual
346 Moving Average from Data Stream βœ… βœ… ❌ Visual
424 Longest Repeating Character Replacement βœ… βœ… βœ… Visual
567 Permutation in String βœ… βœ… βœ… Visual

Stack πŸ“š

# Problem 🐍 β˜• 🌊 πŸ“Š
20 Valid Parentheses βœ… βœ… βœ… Visual
22 Generate Parentheses βœ… βœ… βœ… Visual
32 Longest Valid Parentheses βœ… βœ… ❌ Visual
84 Largest Rectangle in Histogram βœ… βœ… βœ… Visual
150 Evaluate Reverse Polish Notation βœ… βœ… βœ… Visual
155 Min Stack βœ… βœ… βœ… Visual
716 Max Stack βœ… βœ… ❌ Visual
739 Daily Temperatures βœ… βœ… βœ… Visual
853 Car Fleet βœ… βœ… βœ… Visual
1249 Minimum Remove to Make Valid Parentheses βœ… βœ… βœ… Visual

Binary Search πŸ”

# Problem 🐍 β˜• 🌊 πŸ“Š
4 Median of Two Sorted Arrays βœ… βœ… βœ… Visual
33 Search in Rotated Sorted Array βœ… βœ… βœ… Visual
34 Find First and Last Position of Element βœ… βœ… βœ… Visual
74 Search a 2D Matrix βœ… βœ… βœ… Visual
153 Find Minimum in Rotated Sorted Array βœ… βœ… βœ… Visual
704 Binary Search βœ… βœ… βœ… Visual
875 Koko Eating Bananas βœ… βœ… βœ… Visual
981 Time Based Key-Value Store βœ… βœ… βœ… Visual

Linked List πŸ”—

# Problem 🐍 β˜• 🌊 πŸ“Š
2 Add Two Numbers βœ… βœ… βœ… Visual
19 Remove Nth Node From End of List βœ… βœ… βœ… Visual
21 Merge Two Sorted Lists βœ… βœ… βœ… Visual
23 Merge K Sorted Lists βœ… βœ… βœ… Visual
24 Swap Nodes in Pairs βœ… ❌ ❌ Visual
25 Reverse Nodes in k-Group βœ… βœ… βœ… Visual
138 Copy List with Random Pointer βœ… βœ… βœ… Visual
141 Linked List Cycle βœ… βœ… βœ… Visual
143 Reorder List βœ… βœ… βœ… Visual
146 LRU Cache βœ… βœ… βœ… Visual
148 Sort List βœ… βœ… βœ… Visual
206 Reverse Linked List βœ… βœ… βœ… Visual
234 Palindrome Linked List βœ… βœ… ❌ Visual
287 Find the Duplicate Number βœ… βœ… βœ… Visual
876 Middle of the Linked List βœ… βœ… ❌ Visual

Trees 🌳

# Problem 🐍 β˜• 🌊 πŸ“Š
94 Binary Tree Inorder Traversal βœ… ❌ ❌ Visual
98 Validate Binary Search Tree βœ… βœ… βœ… Visual
100 Same Tree βœ… βœ… βœ… Visual
101 Symmetric Tree βœ… βœ… ❌ Visual
102 Binary Tree Level Order Traversal βœ… βœ… βœ… Visual
103 Binary Tree Zigzag Level Order Traversal βœ… βœ… ❌ Visual
104 Maximum Depth of Binary Tree βœ… βœ… βœ… Visual
105 Construct Binary Tree from Preorder and Inorder βœ… ❌ βœ… Visual
108 Convert Sorted Array to Binary Search Tree βœ… ❌ ❌ Visual
110 Balanced Binary Tree βœ… βœ… βœ… Visual
111 Minimum Depth of Binary Tree βœ… ❌ ❌ Visual
112 Path Sum βœ… ❌ ❌ Visual
113 Path Sum II βœ… ❌ ❌ Visual
114 Flatten Binary Tree to Linked List βœ… βœ… ❌ Visual
124 Binary Tree Maximum Path Sum βœ… βœ… βœ… Visual
199 Binary Tree Right Side View βœ… βœ… βœ… Visual
208 Implement Trie (Prefix Tree) βœ… βœ… βœ… Visual
211 Design Add and Search Words Data Structure βœ… βœ… βœ… Visual
212 Word Search II βœ… βœ… βœ… Visual
226 Invert Binary Tree βœ… βœ… βœ… Visual
230 Kth Smallest Element in a BST βœ… βœ… βœ… Visual
235 Lowest Common Ancestor of a BST βœ… βœ… βœ… Visual
297 Serialize and Deserialize Binary Tree βœ… βœ… βœ… Visual
366 Find Leaves of Binary Tree βœ… βœ… ❌ Visual
543 Diameter of Binary Tree βœ… βœ… βœ… Visual
572 Subtree of Another Tree βœ… βœ… βœ… Visual
1448 Count Good Nodes in Binary Tree βœ… βœ… βœ… Visual

Heap / Priority Queue ⛰️

# Problem 🐍 β˜• 🌊 πŸ“Š
215 Kth Largest Element in an Array βœ… βœ… βœ… Visual
295 Find Median from Data Stream βœ… βœ… βœ… Visual
355 Design Twitter βœ… βœ… βœ… Visual
621 Task Scheduler βœ… βœ… βœ… Visual
703 Kth Largest Element in a Stream βœ… βœ… βœ… Visual
973 K Closest Points to Origin βœ… βœ… βœ… Visual
1046 Last Stone Weight βœ… βœ… βœ… Visual
1851 Minimum Interval to Include Each Query βœ… βœ… βœ… Visual

Graphs πŸ—ΊοΈ

# Problem 🐍 β˜• 🌊 πŸ“Š
127 Word Ladder βœ… βœ… βœ… Visual
130 Surrounded Regions βœ… βœ… βœ… Visual
133 Clone Graph βœ… βœ… βœ… Visual
200 Number of Islands βœ… βœ… βœ… Visual
207 Course Schedule βœ… βœ… βœ… Visual
210 Course Schedule II βœ… βœ… βœ… Visual
261 Graph Valid Tree βœ… βœ… βœ… Visual
269 Alien Dictionary βœ… βœ… βœ… Visual
277 Find the Celebrity βœ… βœ… ❌ Visual
286 Walls and Gates βœ… βœ… ❌ Visual
323 Number of Connected Components βœ… βœ… βœ… Visual
329 Longest Increasing Path in a Matrix βœ… βœ… βœ… Visual
332 Reconstruct Itinerary βœ… βœ… βœ… Visual
417 Pacific Atlantic Water Flow βœ… βœ… βœ… Visual
547 Number of Provinces βœ… βœ… ❌ Visual
684 Redundant Connection βœ… βœ… βœ… Visual
695 Max Area of Island βœ… βœ… βœ… Visual
743 Network Delay Time βœ… βœ… βœ… Visual
778 Swim in Rising Water βœ… βœ… βœ… Visual
787 Cheapest Flights Within K Stops βœ… βœ… βœ… Visual
994 Rotting Oranges βœ… βœ… βœ… Visual
1584 Min Cost to Connect All Points βœ… βœ… βœ… Visual

Dynamic Programming πŸ“ˆ

# Problem 🐍 β˜• 🌊 πŸ“Š
5 Longest Palindromic Substring βœ… βœ… βœ… Visual
10 Regular Expression Matching βœ… βœ… βœ… Visual
45 Jump Game II βœ… βœ… βœ… Visual
53 Maximum Subarray βœ… βœ… βœ… Visual
55 Jump Game βœ… βœ… βœ… Visual
62 Unique Paths βœ… βœ… βœ… Visual
70 Climbing Stairs βœ… βœ… βœ… Visual
72 Edit Distance βœ… βœ… βœ… Visual
91 Decode Ways βœ… βœ… βœ… Visual
97 Interleaving String βœ… βœ… βœ… Visual
115 Distinct Subsequences βœ… βœ… βœ… Visual
139 Word Break βœ… βœ… βœ… Visual
152 Maximum Product Subarray βœ… βœ… βœ… Visual
198 House Robber βœ… βœ… βœ… Visual
213 House Robber II βœ… βœ… βœ… Visual
300 Longest Increasing Subsequence βœ… βœ… βœ… Visual
309 Best Time to Buy and Sell Stock with Cooldown βœ… βœ… βœ… Visual
312 Burst Balloons βœ… βœ… βœ… Visual
322 Coin Change βœ… βœ… βœ… Visual
416 Partition Equal Subset Sum βœ… βœ… βœ… Visual
494 Target Sum βœ… βœ… βœ… Visual
518 Coin Change II βœ… βœ… βœ… Visual
647 Palindromic Substrings βœ… βœ… βœ… Visual
746 Min Cost Climbing Stairs βœ… βœ… βœ… Visual
818 Race Car βœ… βœ… ❌ Visual
1143 Longest Common Subsequence βœ… βœ… βœ… Visual

Greedy πŸ€‘

# Problem 🐍 β˜• 🌊 πŸ“Š
134 Gas Station βœ… βœ… βœ… Visual
179 Largest Number βœ… βœ… ❌ Visual
678 Valid Parenthesis String βœ… βœ… βœ… Visual
763 Partition Labels βœ… βœ… βœ… Visual
846 Hand of Straights βœ… βœ… βœ… Visual
1899 Merge Triplets to Form Target Triplet βœ… βœ… βœ… Visual

Backtracking ↩️

# Problem 🐍 β˜• 🌊 πŸ“Š
17 Letter Combinations of a Phone Number βœ… ❌ βœ… Visual
39 Combination Sum βœ… βœ… βœ… Visual
40 Combination Sum II βœ… βœ… βœ… Visual
46 Permutations βœ… βœ… βœ… Visual
51 N-Queens βœ… βœ… βœ… Visual
78 Subsets βœ… βœ… βœ… Visual
79 Word Search βœ… βœ… βœ… Visual
90 Subsets II βœ… βœ… βœ… Visual
131 Palindrome Partitioning βœ… βœ… βœ… Visual

Math & Geometry πŸ“

# Problem 🐍 β˜• 🌊 πŸ“Š
7 Reverse Integer βœ… βœ… βœ… Visual
43 Multiply Strings βœ… βœ… βœ… Visual
48 Rotate Image βœ… βœ… βœ… Visual
50 Pow(x, n) βœ… βœ… βœ… Visual
54 Spiral Matrix βœ… βœ… βœ… Visual
66 Plus One βœ… βœ… βœ… Visual
73 Set Matrix Zeroes βœ… βœ… βœ… Visual
136 Single Number βœ… βœ… βœ… Visual
190 Reverse Bits βœ… βœ… βœ… Visual
191 Number of 1 Bits βœ… βœ… βœ… Visual
268 Missing Number βœ… βœ… βœ… Visual
338 Counting Bits βœ… βœ… βœ… Visual
371 Sum of Two Integers βœ… βœ… βœ… Visual
2013 Detect Squares βœ… βœ… ❌ Visual

Intervals πŸ“…

# Problem 🐍 β˜• 🌊 πŸ“Š
56 Merge Intervals βœ… βœ… βœ… Visual
57 Insert Interval βœ… βœ… βœ… Visual
252 Meeting Rooms βœ… βœ… βœ… Visual
253 Meeting Rooms II βœ… βœ… βœ… Visual
435 Non-overlapping Intervals βœ… βœ… βœ… Visual
759 Employee Free Time βœ… βœ… ❌ Visual
1272 Remove Interval βœ… βœ… ❌ Visual

String πŸ”€

# Problem 🐍 β˜• 🌊 πŸ“Š
6 Zigzag Conversion βœ… ❌ ❌ Visual
8 String to Integer (atoi) βœ… ❌ ❌ Visual
9 Palindrome Number βœ… ❌ ❌ Visual
12 Integer to Roman βœ… ❌ ❌ Visual
13 Roman to Integer βœ… βœ… ❌ Visual
14 Longest Common Prefix βœ… βœ… ❌ Visual
31 Next Permutation βœ… βœ… ❌ Visual
41 First Missing Positive βœ… βœ… ❌ Visual
68 Text Justification βœ… βœ… ❌ Visual

Design πŸ—οΈ

# Problem 🐍 β˜• 🌊 πŸ“Š
348 Design Tic-Tac-Toe βœ… βœ… ❌ Visual
359 Logger Rate Limiter βœ… βœ… ❌ Visual

Summary by Problem Count

Category Python 🐍 Java β˜• Visuals πŸ“Š
Array & Hashing 18 16 18
Two Pointers 5 5 5
Sliding Window 7 7 7
Stack 10 9 10
Binary Search 8 8 8
Linked List 15 14 15
Trees 27 23 27
Heap / Priority Queue 8 8 8
Graphs 21 21 21
Dynamic Programming 27 27 27
Greedy 6 6 6
Backtracking 9 8 9
Math & Geometry 14 14 14
Intervals 7 7 7
String 9 6 9
Design 2 2 2
TOTAL 193 178 193

How to Use πŸ€”

  1. Navigate to the category you're interested in
  2. Pick a problem and review the solution (🐍 for Python, β˜• for Java)
  3. Check if it's part of NeetCode 150 (🌊) for interview prep priority
  4. Open the visualization (πŸ“Š) for step-by-step algorithm animation

Source

These solutions were adapted from the freeCodeCamp article on NeetCode 150 and refactored into this organized format.

License πŸ“„

MIT License.

About

Convert freeCodeCamp Java Code to Python with step-by-step visuals πŸ–ΌοΈ and animations 🎞️ | NeetCode 150 🧩

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors