Around 200 Leetcode.com and 77 Algoexpert.io problems with solutions using Swift and Python
This repo contains my solutions to algorithmic problems in leetcode.com and algoexpert.io written in Swift and Python .
Here is my leetcode profile .
Show your support by giving it a STAR
About •
Topics •
Tips •
LeetCode.com •
AlgoExpert.io •
References
I have solved quite a number of problems from several topics. See the below table for further details.
Binary Search
Binary Search Tree
Binary Tree(Segment Tree)
N-aray Tree(Trie, Binary Indexed Tree)
Graph(Dijkstra, Union Find, Kruskal, Prim's, Minimum Spanning Tree, Topological Ordering...etc)
Stack
Queue
Array
Sorting
Hash Table
Heap
Linked list
Bit Operation
Dynamic programming
Backtracking(Permutations & Combinations & Subsets...etc)
Math
and more...
Whenever you solve a new question with some new techniques/algorithms, try to solve atleast 2 similar problem in a row. This way, your understanding to the new techniques/algorithms will be better.
...
#
Title
Solution
Tutorial
Level
Remarks
01
704. Binary Search
Python
03
240. Search a 2D Matrix II
Python
Video 01 , Video 02
04
74. Search a 2D Matrix
Python
Video 01 , Video 02
05
1011. Capacity To Ship Packages Within D Days
Python
Discussion 1 , Discussion 2 , Discussion 3
Medium
Difficult to spot the pattern, revise again
06
410. Split Array Largest Sum
Python
Article 01
Hard
📌 Not done
07
4. Median of Two Sorted Arrays
Python
Article 01 , Video 1
Hard
📌 Classic problem
08
981. Time Based Key-Value Store
Python
Article 01
Medium
📌
09
222. Count Complete Tree Nodes
Python
Theory , Official Solution , Fantastic idea!
Medium
📌 BS within BS
10
1231. Divide Chocolate
Python
Art 1 , Art 2 , Art 3 , Vid 1
Hard
📌 Not done. Check again. Solve all similar question
(BFS, DFS, Dijkstra, Union Find, Kruskal, Prim's, Minimum Spanning Tree, Topological Ordering...etc)
#
Title
Solution
Tutorial
Level
Remarks
01
211. Add and Search Word. Data structure design
Python
Video 01 , Video 02
02
37. Sudoku Solver
Python
Video 01 , Video 02
03
52. N-Queens II
Python
Video 01 , Video 02
04
784. Letter Case Permutation
Python
---
Easy
Backtracking Fundamentals
05
22. Generate Parentheses
Python
Video 1 , Article 1
Medium
Backtracking Fundamentals
06
17. Letter Combinations of a Phone Number
Python
Video 1 , Video 2 - paid course , Article 1
Medium
Backtracking Fundamentals
07
46. Permutations
Python
Video 1 - paid course , Article 1 , Article 2
Medium
Backtracking Fundamentals
08
39. Combination Sum
Python
Article 1 , Article 2
Medium
Backtracking Fundamentals
09
79. Word Search
Python
Article 1
Medium
Backtracking Fundamentals
10
78. Subsets
Python
Video 1 , Video 2 , Video 3 , Article 1
Medium
📌 TODO: check bit manipulation
11
77. Combinations
Python
Video 1 - paid course
Medium
📌 TODO: Not done. Hard to grasp. Check again
12
1066. Campus Bikes II
Python
Algo Notes
Medium
📌 TODO: Backtracking solution is getting TLE. Solve it and implement it with DP also
13
1087. Brace Expansion
Python
---
Medium
📌 ---
14
1219. Path with Maximum Gold
Python
---
Medium
📌 ---
#
Title
Solution
Tutorial
Level
Remarks
01
1055. Shortest Way to Form String
Python
Art 1 , Art 2
Medium
📌 Check BS approach again
02
1057. Campus Bikes
Python
Video 01 , Article 01
Medium
📌 Solve 1066. Campus Bikes II using DP , DFS and Priority Queue
03
1007. Minimum Domino Rotations For Equal Row
Python
Official , Article 01
Medium
📌 Hard to spot if it is a Greedy
04
406. Queue Reconstruction by Height
Python
Article 1 , Article 2
Medium
📌 Fundamentals
05
621. Task Scheduler
Python
Ex 1 , Ex 2 , Vid 1 , Vid 2 , Vid 3 , Vid 4
Medium
📌 Extremely tricky. Classic problem
06
392. Is Subsequence
Python
Ex 1 , Ex 3
Easy
📌
07
55. Jump Game
Python
Official , Art 1
Medium
📌 Must Check. Learned a lot
08
45. Jump Game II
Python
Vid 1 , Vid 2 , Vid 3 , Art 1
Hard
📌
09
767. Reorganize String
Python
---
Medium
Also check Heap approach
10
435. Non-overlapping Intervals
Python
Vid 1 , Art 1
Medium
Classic problem
#
Title
Solution
Tutorial
Level
Remarks
01
53. Maximum Subarray
Python
02
518. Coin Change 2
Python
03
322. Coin Change
Python
04
72. Edit Distance
Python
Video 01
05
70. Climbing Stairs
Python
06
96. Unique Binary Search Trees
Python
Video 01 , Video 02
07
95. Unique Binary Search Trees II
Python
08
221. Maximal Square
Python
Video 01 , Video 02
09
85. Maximal Rectangle
Python
Video 01
10
42. Trapping Rain Water
Python
Article 01
Hard
📌 Check stack and 2 pointers based solutions
11
300. Longest Increasing Subsequence
Python
Article 01
Medium
📌 Need to check Binary Search approach, which is a lot harder
12
1143. Longest Common Subsequence
Python
---
Medium
📌 Classic DP
13
5. Longest Palindromic Substring
Python
---
Medium
📌 Classic DP
14
1066. Campus Bikes II
Python
Medium
📌 TODO: Backtracking solution is getting TLE. Solve it and implement it with DP also
15
121. Best Time to Buy and Sell Stock
Python
Vid 1
Easy
Fundamental
16
122. Best Time to Buy and Sell Stock II
Python
Video 01
Easy
More like Greedy
17
123. Best Time to Buy and Sell Stock III
Python
Vid 1 , Vid 2
Hard
Fundamental
18
188. Best Time to Buy and Sell Stock IV
Python
Vid 1 , Vid 2
Hard
Getting "Memory Limit Exceeded"
19
309. Best Time to Buy and Sell Stock with Cooldown
Python
Must , Art0 , Art1 , Must 2 , Art 2 , Art 3 ,
Medium
Very tricky, must check again. Couldn't solve
20
714. Best Time to Buy and Sell Stock with Transaction Fee
Python
Must Read , Art 2
Medium
More like Greedy, but DP
#
Title
Solution
Tutorial
Level
Remarks
01
78. Subsets
Python
Video 1 , Video 2 , Video 3
Medium
📌 TODO: code it in all 4 ways. First complete DFS, BFS, Bit Manipulation and some easy back tracking problem. ⭐ 😭 Didn't understand, check again
02
136. Single Number
Python
---
Easy
📌 The key here is to practice bit operation, i ignore any other attempts
03
461. Hamming Distance
Python
---
Easy
📌 The key here is to practice bit operation, i ignore any other attempts
04
371. Sum of Two Integers
Python
Video 1 , Atricle 1
Easy
📌 The key here is to practice bit operation, i ignore any other attempts
05
169. Majority Element
Python
Atricle 1
Easy
📌 The key here is to practice bit operation, i ignore any other attempts
06
191. Number of 1 Bits
Python
Article 1
Easy
📌 The key here is to practice bit operation
07
137. Single Number II
Python
1 , 2 , 3 , Check discussion
Medium
⭐ 😭 Didn't understand, check again
08
389. Find the Difference
Python
---
Easy
📌
09
231. Power of Two
Python
Official , Signed number representations
Easy
📌 Learned few very important binary logic properties
10
268. Missing Number
Python
Official
Easy
📌 Learned few very important binary logic properties
11
187. Repeated DNA Sequences
Python
Official
Medium
⭐ 😭 Didn't understand, check again
77 Problems
Some helpful links, channels, tutorials, blogs.
Strategies
How a Googler solves coding problems
Nail Every Coding Interview by Becoming Asymmetrical
How to get into FAANG
Preparing for Programming interview with Python
The 30-minute guide to rocking your next coding interview
Google Interview Part-1 , Google Interview Part-2 , Google Interview Part-3 , Final Part
Amazon ও Google এ চাকরির সুযোগ পাওয়ার প্রস্তুতি পর্ব
How to use LeetCode effectively
How to solve ANY interview question
How To Ace The Google Coding Interview - Complete Guide
Software Engineering Interviews: The Golden Path To Passing
A MUST READ
Courses/Books
Data Structures in Python: An Interview Refresher
Grokking the Coding Interview: Patterns for Coding Questions
Grokking Dynamic Programming Patterns for Coding Interviews
Coding Interview Class
Competitive Programmer’s Handbook
Python
Learn the following modules by heart. Just knowing all of the following items will made most of the problem one-liners.
itertools - Functions creating iterators for efficient looping - They will help you, more often than you think
collections - High-performance container datatypes - Believe me, this is pretty awesome
heapq - Heap queue algorithm - Obviously, we don't have to hand-code heaps anymore
bisect - Array bisection algorithm - Binary Search, simplified
Set
Dict - Now on, hash Tables are fun to work with
Sorting - Don't participate in competitions without reading this completely.
Start using lambda extensively
functools
Apart from these, all the builtin methods of default containers.
Understanding slice notation - you will need/use it more than you can imagine
Channels
Tushar Roy - Coding Made Simple
Back To Back SWE
William Fiset
Irfan Baqui
Tree (Tree, BST, BIT, Segment Tree, N-aray Tree, Trie etc)
Fenwick Tree or Binary Indexed Tree - youtube
Binary Indexed Tree or Fenwick Tree - geeksforgeeks
Binary Indexed Tree or Fenwick Tree - topcoder
Segment Tree Range Minimum Query - youtube
Segment Tree | Set 1 (Sum of given range) - geeksforgeeks
Practical Data Structures for Frontend Applications: When to use Segment Trees
What is the difference between a binary indexed tree and a segment tree?
How does one decide when to use a Segment Tree or Fenwick Tree?
What are the differences between segment trees, interval trees, binary indexed trees and range trees?
Graph(Dijkstra, Union Find, Kruskal, Prim's, Minimum Spanning Tree, Topological Ordering...etc)
Graph Theory Playlist
Union Find [Disjoint Set] Playlist
Disjoint Sets Data Structure - Weighted Union and Collapsing Find
Bit Manipulation
Bit Manipulation - youtube
Conversion of Binary, Octal and Hexadecimal Numbers
Your guide to Bit Manipulation
Python Bitwise Operators
Add Two Numbers Without The "+" Sign (Bit Shifting Basics)
Binary Arithmetic
1’s and 2’s complement of a Binary Number
What is “2's Complement”?
Bits manipulation (Important tactics)
Bit Manipulation
Python Bitwise Operators
XOR - The magical bitwise operator
A summary: how to use bit manipulation to solve problems easily and efficiently - leetcode
Bit Manipulation 4% of LeetCode Problems
Coding Interview University - Bitwise operations
Mask (computing)
What is Bit Masking?
Understanding Bit masks
Bitmasks: A very esoteric (and impractical) way of managing booleans
Hacker’s Delight - BOOK
Bitwise operators — Facts and Hacks
Signed number representations
Dynamic Programming
The FAST method
A good approach to attack DP
Tabulation vs Memoization
Memoization vs Tabulation
Greedy
Greedy Method - Introduction
Introduction to Greedy Method
Introduction to Greedy Algorithms | GeeksforGeeks
Basics of Greedy Algorithms
When to try greedy algorithms on problems?
How to spot a “greedy” algorithm?
DP VS Greedy
Greedy Algorithm and Dynamic Programming
Greedy approach vs Dynamic programming
What is the difference between dynamic programming and greedy approach?
Backtracking
Backtracking - wiki
Backtracking | Introduction
Introduction to Backtracking - Brute Force Approach
Branch and Bound Introduction
The Backtracking Blueprint: The Legendary 3 Keys To Backtracking Algorithms
Backtracking explained
Foundation of algorithms - Chapter 5 (Backtracking) notes
Backtracking Search Algorithms
Recursion
Learning to think with recursion, part 1
Learning to think with recursion, part 2
What makes a data structure recursive?
Binary Tree as a Recursive Data Structure
Recursion Visualizer - use Viz Mode
Thinking Recursively in Python
Breaking out of a recursive function?
Why does recursion return the first call in the stack and not the last?