Skip to content

wena04/Leetcode-and-Others

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anthony's Leetcode and Other Practice

Using Python or Java to answer leet code and other problems to prep for tech interviews

Last updated: April 18, 2026

Milestones

PayPal Internship Prep (Complete - April 2026)

~83 LeetCode problems covering arrays, hashmaps, two pointers, sliding window, linked lists, stacks, binary trees, graphs, dynamic programming, and more.


# Title Solution Time/Space Complexity Methods/Notes Date Completed
1 Two Sum Python Java O(N)/O(N) Hashmap to see if seen the target num subtracted by current number -> return value if have May 25, 2024
9 Palindrome Number Python O(N)/O(1) Convert to string and compare with two pointers Sep 26, 2025
14 Longest Common Prefix Python Java O(N)/O(M) for both set empty string, iterate through all the strings at once (need 2 for loops), return when i == len(s) or s[i] != strs[0][i] Apirl 04, 2024
20 Valid Parentheses Python O(N)/O(N) Stack, push matching close bracket, pop when match found Feb 7, 2025
21 Merge Two Sorted Lists Java O(N)/O(N) Creating a new linked list and add in required order June 5, 2024
26 Remove Duplicates from Sorted Array Python O(N)/O(1) Two pointers, swap unique values to front Feb 23, 2025
27 Remove Element Python O(N)/O(1) Swap valid elements to front of array in-place Feb 10, 2025
83 Remove Duplicates from Sorted List Python O(N)/O(1) Iterate through, skip duplicates by adjusting next pointers Dec 16, 2025
88 Merge Sorted Array Python O(N)/O(1) Merge in reverse order, fill from end of nums1 Feb 23, 2025
101 Symmetric Tree Python O(N)/O(h) Recursive mirror check comparing left.left with right.right Feb 25, 2025
104 Maximum Depth of Binary Tree Python O(N)/O(N) DFS, return 1 + max depth of left and right subtrees Feb 26, 2025
111 Minimum Depth of Binary Tree Python O(N)/O(N) DFS returning min depth of left and right subtrees Dec 20, 2025
118 Pascal's Triangle Python Java O(N^2)/O(N^2) Dynamic Programming -> every row is a list/array itself -> recursive calling itself to use previous row to calculate current row May 25, 2024
125 Valid Palindrome Java O(N)/O(1) Two pointers, start at each end and compare June 1, 2024
169 Majority Element Python M1: O(N)/O(N)
M2: O(N)/O(1)
M1: Hashmap freq count
M2: Boyer-Moore voting algorithm
Feb 23, 2025
203 Remove Linked List Elements Python O(N)/O(1) Dummy node + prev/curr pointers, skip matching nodes Feb 24, 2025
206 Reverse Linked List Python Java M1: O(N)/O(1)
M2: O(N)/O(N)
M1: Iteratively M2:Recursively June 5, 2024
217 Contains Duplicate Python M1: O(N^2)/O(1)
M2: O(NlogN)/O(logN)
M3: O(N)/O(N)
M1: Brute Force
M2: sort array first, compare adjacent elements
M3: put elements into HashMap -> containsKey then return true, else false
May 25, 2024
242 Valid Anagram Python M1: O(N)/O(N)
M2: O(NlogN)/O(1) but could also be said to be O(N) for space
M1: using Hashmap to count number of each character
M2: sort the string first
May 26, 2024
268 Missing Number Python O(N)/O(N) Put nums in set, iterate 0 to n to find missing Dec 15, 2025
270 Closest Binary Search Tree Value Python O(logN)/O(logN) DFS using BST property to go left/right based on target Dec 20, 2025
283 Move Zeroes Python O(N)/O(1) Two pointers, swap non-zero values to front Feb 23, 2025
344 Reverse String Python Java O(N)/O(1) Two pointers, start at each end and swap characters Dec 14, 2025
346 Moving Average from Data Stream Python O(1)/O(N) Queue with running sum, pop oldest when exceeding size Dec 17, 2025
349 Intersection of Two Arrays Python O(N*M)/O(N) Iterate shorter array, check if in longer and not in result Mar 21, 2026
383 Ransom Note Python O(N+M)/O(N+M) Hashmap freq count for both strings, compare counts Dec 16, 2025
409 Longest Palindrome Python O(N)/O(1) Set to track pairs, count matched pairs * 2, +1 if any remain Feb 26, 2025
448 Find All Numbers Disappeared in an Array Python O(N)/O(1) Mark visited indices negative, remaining positives are missing Mar 23, 2026
485 Max Consecutive Ones Python O(N)/O(1) Track last seen 0, calculate distance from it Mar 23, 2026
496 Next Greater Element I Python O(N+M)/O(N+M) Monotonic stack to find next greater in nums2, hashmap for nums1 indices Dec 19, 2025
543 Diameter of Binary Tree Python O(N)/O(N) DFS returning height, track max left+right at each node Dec 20, 2025
557 Reverse Words in a String III Python O(N)/O(N) Two pointers to reverse each word individually Dec 15, 2025
643 Maximum Average Subarray I Python O(N)/O(1) Fixed sliding window, maintain sum by adding/removing elements Dec 15, 2025
645 Set Mismatch Python O(N)/O(1) Mark visited as negative, find duplicate (already negative) and missing (still positive) Mar 23, 2026
671 Second Minimum Node in a Binary Tree Java O(N)/O(N) DFS -- preorder traversal but custom towards this special kind of tree -> think case by case Apirl 23, 2024
746 Min Cost Climbing Stairs Java O(N)/O(1) DP -> base case first two steps -> loop curr = cost[i] + min(first,second), first = second, second = curr Apirl 20, 2024
771 Jewels and Stones Python O(N+M)/O(N+M) Hashmap freq count for both, sum matching keys Dec 16, 2025
876 Middle of Linked List Python Python O(N)/O(1) Slow/fast pointers Dec 16, 2025
929 Unique Email Addresses Python O(N)/O(N) Set + character building, handle dots and plus in local name Sep 27, 2025
977 Squares of a Sorted Array Python O(N)/O(N) Two pointers from both ends, fill result array from back Dec 14, 2025
1071 Greatest Common Divisor of Strings Python O(min(m,n)*(n+m))/O(1) Try substrings from largest, check if it divides both strings Feb 23, 2025
1133 Largest Unique Number Python O(N)/O(N) Hashmap freq count, find largest with count of 1 Dec 16, 2025
1189 Maximum Number of Balloons Python O(N)/O(1) Count chars in "balloon", divide l and o by 2, return min Dec 16, 2025
1200 Minimum Absolute Difference Python O(NlogN)/O(N) Sort array, find min diff, collect all pairs with that diff Dec 23, 2025
1207 Unique Number of Occurrences Python O(N)/O(N) Hashmap freq count, check len(freq) == len(set of values) Feb 23, 2025
1365 How Many Numbers Are Smaller Than the Current Number Python O(NlogN)/O(N) Hashmap freq count, sort keys, prefix sum of counts Mar 23, 2026
1413 Minimum Value to Get Positive Step by Step Sum Python O(N)/O(N) Prefix sum, find minimum prefix and return its negation + 1 Dec 15, 2025
1426 Counting Elements Python O(N)/O(N) Put all in set, count elements where element+1 exists Dec 15, 2025
1431 Kids with the Greatest Number of Candies Python O(N)/O(N) Find max candy first, check each kid + extra >= max Feb 23, 2025
1470 Shuffle the Array Python O(N)/O(N) Two pointers, left at start and right at middle, interleave Mar 23, 2026
1480 Running Sum of 1d Array Python O(N)/O(N) Build prefix sum array Dec 15, 2025
1544 Make The String Great Python O(N)/O(N) Stack, pop if top and current are same letter different case Dec 17, 2025
1768 Merge Strings Alternately Python O(N)/O(N) Loop shorter string, add chars alternately, append remainder Feb 7, 2025
1832 Check if the Sentence Is Pangram Python O(N)/O(1) Set of characters, check if length is 26 Dec 15, 2025
1929 Concatenation of Array Python O(N)/O(N) Return nums + nums Feb 24, 2026
1971 Find if Path Exists in Graph Python O(V+E)/O(V+E) Build adjacency list, DFS from source to destination Dec 21, 2025
# Title Solution Time/Space Complexity Methods/Notes Date Completed
3 Longest Substring Without Repeating Characters Python Python Java O(N)/O(N) Sliding window with hashmap or hashset to track seen chars Dec 16, 2025
11 Container With Most Water Java O(N)/O(1) two pointers, starting at opposite ends, move smaller pointer after testing area June 5, 2024
33 Search in Rotated Sorted Array Java O(logN)/O(1) binary search June 5, 2024
49 Group Anagrams Python O(N)/O(N)) HashMap of charCount to the words that can make this anagram May 31, 2024
56 Merge Intervals Python O(NlogN)/O(N) Sort by start, merge overlapping end values Dec 23, 2025
71 Simplify Path Python O(N)/O(N) Stack, split by /, handle .. and . cases Dec 17, 2025
92 Reverse Linked List II Python O(N)/O(1) Dummy node, iterate to left position, reverse sublist in-place Dec 17, 2025
102 Binary Tree Level Order Traversal Python O(N)/O(N) BFS with queue, process nodes level by level Feb 26, 2025
103 Binary Tree Zigzag Level Order Traversal Python O(N)/O(N) BFS level order, reverse odd levels Dec 20, 2025
128 Longest Consecutive Sequence Python O(N)/O(N) Set + find sequence starts (no left neighbor), count length Feb 7, 2025
143 Reorder List Java O(N)/O(N) two pointers, one at each end but with linked lists June 5, 2024
151 Reverse Words in a String Python O(N)/O(N) Strip spaces, deque to push words in reverse order Feb 23, 2025
155 Min Stack Java O(1)/O(N) Two stacks, main stack + auxiliary min stack Feb 26, 2025
300 Longest Increasing Subsequence Python O(N^2)/O(N) DP, track LIS length at each index from right to left Dec 23, 2025
323 Number of Connected Components in an Undirected Graph Python O(V+E)/O(V+E) Build adjacency list, DFS to count connected components Dec 21, 2025
347 Top K Frequent Elements Python M1: O(N)/O(N)
M2: O(NlogK)/O(N)
M1: Bucket Sort + HashMap and then loop through for highest frequencies
M2: Heap/PQ that sort by freq of each quarter, output first k elements
May 31, 2024
Feb 24, 2025
438 Find All Anagrams in a String Python O(N)/O(N) Fixed sliding window with Counter, compare window to target Sep 3, 2025
525 Contiguous Array Python O(N)/O(N) Hashmap tracking first index of zeros-ones difference Dec 16, 2025
560 Subarray Sum Equals k Python O(N)/O(N) Prefix sum hashmap, count freq of (currSum - k) Feb 22, 2025
567 Permutation in String Python O(N)/O(N) Fixed sliding window with Counter, compare window to target Sep 3, 2025
622 Design Circular Queue Java O(1)/O(N) Array with front/rear pointers, circular increment with modulo Feb 26, 2025
695 Max Area of Island Python O(MN)/O(MN) DFS on each unvisited land cell, track max area Dec 22, 2025
701 Insert into a Binary Search Tree Python O(logN)/O(logN) DFS using BST property, insert at null leaf position Dec 20, 2025
743 Network Delay Time Python O(NLogN)/O(N)
O(E*logV) in terms of edges & vertex)
Dikjstra's Algorithm using MinHeap + stack to visit all nodes and see shortest path/weight May 20, 2024
901 Online Stock Span Python O(N)/O(N) Monotonic stack storing [price, span] pairs Dec 20, 2025
912 Sort an Array Java O(NLogN)/O(logN) merge sort May 20, 2024
994 Rotting Oranges Python O(N^2)/O(N) Simulation, update grid state round by round Apr 8, 2026
1004 Max Consecutive Ones III Python O(N)/O(1) Sliding window, track zero count, shrink when > k Dec 15, 2025
1026 Maximum Difference Between Node and Ancestor Python O(N)/O(N) DFS passing max and min ancestor values down Dec 20, 2025
1302 Deepest Leaves Sum Python O(N)/O(N) BFS tracking depth, sum values at deepest level Dec 20, 2025
1657 Determine if Two Strings Are Close Python O(N)/O(1) Hashmap freq, check same unique chars and matching freq distribution Feb 23, 2025
2090 K Radius Subarray Averages Python O(N)/O(N) Prefix sum, calculate average for valid indices Dec 15, 2025
2095 Delete the Middle Node of a Linked List Python O(N)/O(1) Slow/fast pointers, delete node at slow position Feb 24, 2025
2225 Find Players With Zero or One Losses Python O(NlogN)/O(N) Hashmap loss count, separate into zero-loss and one-loss lists Dec 16, 2025
2559 Count Vowel Strings in Ranges Python O(N+Q)/O(N+Q) Prefix sum of vowel-starting-and-ending strings Dec 23, 2025
# Title Solution Time/Space Complexity Methods/Notes Date Completed
32 Longest Valid Parentheses Python O(N)/O(N) Stack storing indices, track last valid position Mar 4, 2025
76 Minimum Window Substring Python Python O(N)/O(N) Sliding window with Counter hashmaps, shrink when all conditions are met Sep 3, 2025
295 Find Median from Data Stream Python O(logN)/O(N) Two heaps (max + min), maintain balanced sizes for O(1) median Dec 23, 2025
2781 Length of the Longest Valid Substring Java O(N * maxlengthofforbidden^2)/O(sum of forbidden words length) Sliding Window + brute Force June 1, 2024

[Other Problems]

Name Solution Time/Space Complexity Methods/Notes Date Completed
UW Programming Competition 2024 -- N. Numerology File Python

About

Using Python or Java to answer leetcode problems

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors