Skip to content

📑 LeetCode problems' Algorithms and Solutions implemented in common PL with explanations and links to further readings.

License

Notifications You must be signed in to change notification settings

ladunjexa/the-leetcode

Repository files navigation


Img

LeetCode Accepted Solutions

License Update SayThanks repo size Linkedin Badge Website Badge

This repository contains accepted solutions of many problems from leetcode including related discussions if exists, coded in different programming languages.

Each problem has its own separate README with related explanations and examples for further reading (including ones to leetcode problem).

Read source-code by Programming Languages: Java, C#, Python, JavaScript, TypeScript

☝ Note that this project is meant to be used for learning and researching purposes only, and it is not meant to be used for production.

Table of Contents

‼️ Folder Structure

Here is the folder structure.

leetcode/
|- algorithms/
|- concurrency/
|- database/
|- javascript/
|- shell/
  ALL FOLDERS ABOVE IN-STRUCTURE IS:
    |-- {problem}/
      |-- Solution.{...}
      |-- README.md

ℹ️ Contents

Algorithms

Database

Shell

JavaScript

Concurrency

(back to top)

🚀 Algorithms

Bit Manipulation

# Title Solution Time Space Difficulty Note
67 Add Binary Java N/A N/A Easy
78 Subsets Java N/A N/A Easy
136 Single Number Java N/A N/A Easy
190 Reverse Bits Java N/A N/A Easy
191 Number of 1 Bits Java N/A N/A Easy
231 Power of Two Java N/A N/A Easy
268 Missing Number Java N/A N/A Easy
287 Find the Duplicate Number Java N/A N/A Medium
338 Counting Bits Java N/A N/A Easy
342 Power of Four Java N/A N/A Easy
389 Find the Difference Java N/A N/A Easy
784 Letter Case Permutation Java O(2^n) O(2^n) Medium View discussion on leetcode
1318 Minimum Flips to Make a OR b Equal to c Java N/A N/A Medium
1342 Number of Steps to Reduce a Number to Zero Java N/A N/A Easy
1863 Sum of All Subset XOR Totals Java N/A N/A Easy

Backtracking

# Title Solution Time Space Difficulty Note
17 Letter Combinations of a Phone Number Java N/A N/A Medium
22 Generate Parentheses Java N/A N/A Medium
37 Sudoku Solver Java N/A N/A Hard
39 Combination Sum Java N/A N/A Medium
51 N-Queens Java N/A N/A Hard
77 Combinations Java N/A N/A Medium
78 Subsets Java N/A N/A Medium
79 Word Search Java N/A N/A Medium
131 Palindrome Partitioning Java N/A N/A Medium
216 Combination Sum III Java N/A N/A Medium
257 Binary Tree Paths Java N/A N/A Easy
784 Letter Case Permutation Java O(2^n) O(2^n) Medium View discussion on leetcode
1863 Sum of All Subset XOR Totals Java N/A N/A Easy

Design

# Title Solution Time Space Difficulty Note
146 LRU Cache Java N/A N/A Medium
155 Min Stack Java N/A N/A Easy
208 Implement Trie (Prefix Tree) Java N/A N/A Medium
225 Implement Stack using Queues Java N/A N/A Easy
232 Implement Queue using Stacks Java N/A N/A Easy
295 Find Median from Data Stream Java N/A N/A Hard
901 Online Stock Span Java N/A N/A Medium
933 Number of Recent Calls Java N/A N/A Easy
2336 Smallest Number in Infinite Set Java N/A N/A Medium

Queue

# Title Solution Time Space Difficulty Note
225 Implement Stack using Queues Java N/A N/A Easy
232 Implement Queue using Stacks Java N/A N/A Easy
239 Sliding Window Maximum Java O(n) O(k) Hard
387 First Unique Character in a String Java N/A N/A Easy
649 Dota2 Senate Java N/A N/A Medium
933 Number of Recent Calls Java N/A N/A Easy

Stack

# Title Solution Time Space Difficulty Note
20 Valid Parentheses Java N/A N/A Easy
32 Longest Valid Parentheses Java N/A N/A Hard
42 Trapping Rain Water Java N/A N/A Hard
84 Largest Rectangle in Histogram Java N/A N/A Hard
94 Binary Tree Inorder Traversal Java N/A N/A Easy
114 Flatten Binary Tree to Linked List Java N/A N/A Medium
144 Binary Tree Preorder Traversal Java N/A N/A Easy
145 Binary Tree Postorder Traversal Java N/A N/A Easy
155 Min Stack Java N/A N/A Easy
225 Implement Stack using Queues Java N/A N/A Easy
232 Implement Queue using Stacks Java N/A N/A Easy
234 Palindrome Linked List Java N/A N/A Easy
394 Decode String Java N/A N/A Medium
735 Asteroid Collision Java O(N + k) O(N) Medium
739 Daily Temperatures Java O(N) O(N) Medium
901 Online Stock Span Java N/A N/A Medium
2130 Leaf Similar Trees Java O(N) O(N) Medium
2390 Removing Stars From a String Java O(N) O(NlogN) Medium

Monotonic Stack

# Title Solution Time Space Difficulty Note
42 Trapping Rain Water Java N/A N/A Hard
84 Largest Rectangle in Histogram Java N/A N/A Hard
739 Daily Temperatures Java O(N) O(N) Medium
901 Online Stock Span Java N/A N/A Medium

Monotonic Queue

# Title Solution Time Space Difficulty Note
239 Sliding Window Maximum Java O(n) O(k) Hard

Brainteaser

# Title Solution Time Space Difficulty Note
292 Nim Game Java N/A N/A Easy

Game Theory

# Title Solution Time Space Difficulty Note
292 Nim Game Java N/A N/A Easy

Sorting

# Title Solution Time Space Difficulty Note
15 3Sum Java N/A N/A Medium
16 3Sum Closest Java N/A N/A Medium
18 4Sum Java N/A N/A Medium
49 Group Anagrams Java N/A N/A Medium
56 Merge Intervals Java N/A N/A Medium
75 Sort Colors Java N/A N/A Medium
148 Sort List Java N/A N/A Medium
169 Majority Element Java N/A N/A Easy
215 Kth Largest Element in an Array Java N/A N/A Medium
217 Contains Duplicate Java N/A N/A Easy
242 Valid Anagram Java N/A N/A Easy
268 Missing Number Java N/A N/A Easy
295 Find Median from Data Stream Java N/A N/A Hard
347 Top K Frequent Elements Java N/A N/A Medium
350 Intersection of Two Arrays II Java N/A N/A Easy
389 Find the Difference Java N/A N/A Easy
414 Third Maximum Number Java N/A N/A Easy
435 Non-overlapping Intervals Java N/A N/A Medium
452 Minimum Number of Arrows to Burst Balloons Java N/A N/A Medium
455 Assign Cookies Java N/A N/A Easy
977 Squares of a Sorted Array Java O(n) O(n) Easy View discussion on leetcode
1337 The K Weakest Rows in a Matrix Java O(nlogm) O(n) Easy View discussion on leetcode
1346 Check If N and Its Double Exist Java N/A N/A Easy
1385 Find the Distance Value Between Two Arrays Java N/A N/A Easy
1491 Average Salary Excluding the Minimum and Maximum Salary Java N/A N/A Easy
1608 Special Array With X Elements Greater Than or Equal X Java O(nlogn) O(1) Easy View discussion on leetcode
1657 Determine if Two Strings Are Close Java O(N) O(1) Medium
1679 Max Number of K-Sum Pairs Java O(N) O(1) Medium
2300 Successful Pairs of Spells and Potions Java N/A N/A Medium
2542 Maximum Subsequence Score Java N/A N/A Medium

Prefix Sum

# Title Solution Time Space Difficulty Note
238 Product of Array Except Self Java O(N) O(N) Medium
560 Subarray Sum Equals K Java N/A N/A Medium
724 Find Pivot Index Java N/A N/A Easy
1004 Max Consecutive Ones III Java O(N + k) O(1) Medium
1480 Running Sum of 1D Array Java N/A N/A Easy
1732 Find the Highest Altitude Java O(N) O(1) Easy

Sliding Window

# Title Solution Time Space Difficulty Note
3 Longest Substring Without Repeating Characters Java N/A N/A Medium
76 Minimum Window Substring Java N/A N/A Hard
219 Contains Duplicate II Java O(N) O(N) Easy
239 Sliding Window Maximum Java O(n) O(k) Hard
438 Find All Anagrams in a String Java N/A N/A Medium
567 Permutation in String Java N/A N/A Medium
643 Maximum Average Subarray I Java O(N) O(1) Easy
1004 Max Consecutive Ones III Java O(N + k) O(1) Medium
1456 Maximum Number of Vowels in a Substring of Given Length Java O(N) O(1) Medium
1493 Longest Subarray of 1's After Deleting One Element Java O(N + k) O(1) Medium

Data Stream

# Title Solution Time Space Difficulty Note
295 Find Median from Data Stream Java N/A N/A Hard
901 Online Stock Span Java N/A N/A Medium
933 Number of Recent Calls Java N/A N/A Easy

Greedy

# Title Solution Time Space Difficulty Note
11 Container With Most Water Java N/A N/A Medium
45 Jump Game II Java N/A N/A Medium
334 Increasing Triplet Subsequence Java O(N) O(1) Medium
435 Non-overlapping Intervals Java N/A N/A Medium
452 Minimum Number of Arrows to Burst Balloons Java N/A N/A Medium
455 Assign Cookies Java N/A N/A Easy
605 Can Place Flowers Java O(N) O(1) Easy
649 Dota2 Senate Java N/A N/A Medium
680 Valid Palindrome II Java N/A N/A Easy
763 Partition Labels Java N/A N/A Medium
1323 Maximum 69 Number Java O(n) O(n) Easy View discussion on leetcode
1855 Maximum Distance Between a Pair of Values Java N/A N/A Medium
2542 Maximum Subsequence Score Java N/A N/A Medium

Graph

# Title Solution Time Space Difficulty Note
207 Course Schedule Java N/A N/A Medium
399 Evaluate Division Java N/A N/A Medium
547 Number of Provinces Java N/A N/A Medium
841 Keys and Rooms Java N/A N/A Medium
1466 Reorder Routes to Make All Paths Lead to the City Zero Java O(n) O(n) Medium View discussion on leetcode

Heap (Priority Queue)

# Title Solution Time Space Difficulty Note
23 Merge k Sorted Lists Java N/A N/A Hard
215 Kth Largest Element in an Array Java N/A N/A Medium
239 Sliding Window Maximum Java O(n) O(k) Hard
295 Find Median from Data Stream Java N/A N/A Hard
347 Top K Frequent Elements Java N/A N/A Medium
1337 The K Weakest Rows in a Matrix Java O(nlogm) O(n) Easy View discussion on leetcode
2336 Smallest Number in Infinite Set Java N/A N/A Medium
2462 Total Cost to Hire K Workers Java N/A N/A Medium
2542 Maximum Subsequence Score Java N/A N/A Medium

Quickselect

# Title Solution Time Space Difficulty Note
215 Kth Largest Element in an Array Java N/A N/A Medium

Shortest Path

# Title Solution Time Space Difficulty Note
399 Evaluate Division Java N/A N/A Medium

Matrix

# Title Solution Time Space Difficulty Note
36 Valid Sudoku Java O(n2) O(1) Medium View discussion on leetcode
37 Sudoku Solver Java N/A N/A Hard
48 Rotate Image Java N/A N/A Medium
64 Minimum Path Sum Java N/A N/A Medium
73 Set Matrix Zeroes Java N/A N/A Medium
74 Search a 2D Matrix Java N/A N/A Medium View discussion on leetcode
79 Word Search Java N/A N/A Medium
200 Number of Islands Java N/A N/A Medium
240 Search a 2D Matrix II Java N/A N/A Medium
542 01 Matrix Java O(nm) O(nm) Medium View discussion on leetcode
695 Max Area of Island Java N/A N/A Medium
733 Flood Fill Java N/A N/A Easy
867 Transpose Matrix Java N/A N/A Easy
994 Rotting Oranges Java N/A N/A Medium
1337 The K Weakest Rows in a Matrix Java O(nlogm) O(n) Easy View discussion on leetcode
1351 Count Negative Numbers in a Sorted Matrix Java N/A N/A Easy
1572 Matrix Diagonal Sum Java O(n) O(1) Easy View discussion on leetcode
1672 Richest Customer Wealth Java N/A N/A Easy
2352 Equal Row and Column Pairs Java O(N^3) O(1) Medium
1926 Nearest Exit from Entrance in Maze Java N/A N/A Medium

Simulation

# Title Solution Time Space Difficulty Note
67 Add Binary Java N/A N/A Easy
258 Add Digits Java N/A N/A Easy
412 Fizz Buzz Java N/A N/A Easy
867 Transpose Matrix Java N/A N/A Easy
2352 Equal Row and Column Pairs Java O(N^3) O(1) Medium
2390 Removing Stars From a String Java O(N) O(NlogN) Medium
2462 Total Cost to Hire K Workers Java N/A N/A Medium
2660 Determine the Winner of a Bowling Game Java, Python, JavaScript O(n) O(1) Easy View discussion on leetcode

Dynamic Programming

# Title Solution Time Space Difficulty Note
5 Longest Palindromic Substring Java N/A N/A Medium
22 Generate Parentheses Java N/A N/A Medium
32 Longest Valid Parentheses Java N/A N/A Hard
42 Trapping Rain Water Java N/A N/A Hard
45 Jump Game II Java N/A N/A Medium
53 Maximum Subarray Java N/A N/A Medium
62 Unique Paths Java N/A N/A Medium View discussion on leetcode
64 Minimum Path Sum Java N/A N/A Medium
70 Climbing Stairs Java N/A N/A Easy
72 Edit Distance Java N/A N/A Medium
121 Best Time to Buy and Sell Stock Java N/A N/A Easy
118 Pascal's Triangle Java O(n^2) O(n^2) Easy View discussion on leetcode
119 Pascal's Triangle II Java O(n) O(n) Easy View discussion on leetcode
121 Best Time to Buy and Sell Stock Java N/A N/A Easy
124 Binary Tree Maximum Path Sum Java N/A N/A Hard
131 Palindrome Partitioning Java N/A N/A Medium
139 Word Break Java N/A N/A Medium
152 Maximum Product Subarray Java N/A N/A Medium
198 House Robber Java O(N) O(N) Medium
279 Perfect Squares Java N/A N/A Medium
300 Longest Increasing Subsequence Java N/A N/A Medium
322 Coin Change Java N/A N/A Medium
338 Counting Bits Java N/A N/A Easy
392 Is Subsequence Java N/A N/A Easy
416 Partition Equal Subset Sum Java N/A N/A Medium
435 Non-overlapping Intervals Java N/A N/A Medium
542 01 Matrix Java O(nm) O(nm) Medium View discussion on leetcode
746 Min Cost Climbing Stairs Java N/A N/A Easy
790 Domino and Tromino Tiling Java N/A N/A Medium
1137 N-th Tribonacci Number Java N/A N/A Easy
1143 Longest Common Subsequence Java N/A N/A Medium
1372 Longest ZigZag Path in a Binary Tree Java N/A N/A Medium
1493 Longest Subarray of 1's After Deleting One Element Java O(N + k) O(1) Medium
1863 Sum of All Subset XOR Totals Java N/A N/A Easy

Divide and Conquer

# Title Solution Time Space Difficulty Note
4 Median of Two Sorted Arrays Java N/A N/A Hard
23 Merge k Sorted Lists Java N/A N/A Hard
53 Maximum Subarray Java N/A N/A Medium
105 Construct Binary Tree from Preorder and Inorder Traversal Java N/A N/A Medium
108 Convert Sorted Array to Binary Search Tree Java N/A N/A Medium
148 Sort List Java N/A N/A Medium
169 Majority Element Java N/A N/A Easy
190 Reverse Bits Java N/A N/A Easy
191 Number of 1 Bits Java N/A N/A Easy
215 Kth Largest Element in an Array Java N/A N/A Medium
240 Search a 2D Matrix II Java N/A N/A Medium
347 Top K Frequent Elements Java N/A N/A Medium

Memoization

# Title Solution Time Space Difficulty Note
70 Climbing Stairs Java N/A N/A Easy
139 Word Break Java N/A N/A Medium
1137 N-th Tribonacci Number Java N/A N/A Easy

Trie

# Title Solution Time Space Difficulty Note
14 Longest Common Prefix Java N/A N/A Hard
139 Word Break Java N/A N/A Medium
208 Implement Trie (Prefix Tree) Java N/A N/A Medium
1268 Search Suggestions System Java N/A N/A Medium

Math

# Title Solution Time Space Difficulty Note
2 Add Two Numbers Java N/A N/A Medium
7 Reverse Integer Java N/A N/A Easy
9 Palindrome Number Java N/A N/A Easy
12 Integer to Roman Java N/A N/A Medium
13 Roman to Integer Java N/A N/A Easy
48 Rotate Image Java N/A N/A Medium
50 Pow(x, n) Java N/A N/A Medium
62 Unique Paths Java N/A N/A Medium View discussion on leetcode
66 Plus One Java N/A N/A Easy
67 Add Binary Java N/A N/A Easy
69 Sqrt(x) Java N/A N/A Easy
70 Climbing Stairs Java N/A N/A Easy
168 Excel Sheet Column Title Java N/A N/A Easy
171 Excel Sheet Column Title Java O(n) O(1) Easy
189 Rotate Array Java N/A O(1) Medium View discussion on leetcode
202 Happy Number Java O(k∗logn) O(k) Easy View discussion on leetcode
231 Power of Two Java N/A N/A Easy
258 Add Digits Java N/A N/A Easy
263 Ugly Number Java N/A N/A Easy
268 Missing Number Java N/A N/A Easy
279 Perfect Squares Java N/A N/A Medium
292 Nim Game Java N/A N/A Easy
326 Power of Three Java O(log3n) O(log3n) Easy View discussion on leetcode
342 Power of Four Java N/A N/A Easy
367 Valid Perfect Square Java N/A N/A Easy
412 Fizz Buzz Java N/A N/A Easy
441 Arranging Coins Java O(logn) O(1) Easy
633 Sum of Square Numbers Java O(n) O(1) Medium
728 Self Dividing Numbers Java N/A N/A Easy
1137 N-th Tribonacci Number Java N/A N/A Easy
1323 Maximum 69 Number Java O(n) O(n) Easy View discussion on leetcode
1342 Number of Steps to Reduce a Number to Zero Java N/A N/A Easy
1822 Sign of the Product of an Array Java N/A N/A Easy
1863 Sum of All Subset XOR Totals Java N/A N/A Easy

Tree

# Title Solution Time Space Difficulty Note
94 Binary Tree Inorder Traversal Java N/A N/A Easy
98 Validate Binary Search Tree Java N/A N/A Medium
100 Same Tree Java N/A N/A Easy
101 Symmetric Tree Java N/A N/A Easy
102 Valid Anagram Java N/A N/A Medium
104 Maximum Depth of Binary Tree Java N/A N/A Easy
105 Construct Binary Tree from Preorder and Inorder Traversal Java N/A N/A Medium
108 Convert Sorted Array to Binary Search Tree Java N/A N/A Easy
110 Balanced Binary Tree Java N/A N/A Easy
111 Minimum Depth of Binary Tree Java N/A N/A Easy
114 Flatten Binary Tree to Linked List Java N/A N/A Medium
116 Populating Next Right Pointers in Each Node Java N/A N/A Medium
124 Binary Tree Maximum Path Sum Java N/A N/A Hard
144 Binary Tree Preorder Traversal Java N/A N/A Easy
145 Binary Tree Postorder Traversal Java N/A N/A Easy
199 Binary Tree Right Side View Java N/A N/A Medium
226 Invert Binary Tree Java N/A N/A Easy
230 Kth Smallest Element in a BST Java N/A N/A Medium
235 Lowest Common Ancestor of a Binary Search Tree Java O(logn) O(logn) Medium View discussion on leetcode
236 Lowest Common Ancestor of a Binary Tree Java N/A N/A Medium
257 Binary Tree Paths Java N/A N/A Easy
404 Sum of Left Leaves Java N/A N/A Easy
437 Path Sum III Java N/A N/A Medium
450 Delete Node in a BST Java N/A N/A Medium
543 Diameter of Binary Tree Java N/A N/A Easy
617 Merge Two Binary Trees Java N/A N/A Easy
653 Two Sum IV - Input is a BST Java N/A N/A Easy
700 Search in a Binary Search Tree Java N/A N/A Easy
701 Insert into a Binary Search Tree Java N/A N/A Medium
872 Leaf Similar Trees Java N/A N/A Easy
1161 Maximum Level Sum of a Binary Tree Java N/A N/A Medium
1372 Longest ZigZag Path in a Binary Tree Java N/A N/A Medium
1448 Count Good Nodes in Binary Tree Java N/A N/A Medium

Binary Search

# Title Solution Time Space Difficulty Note
4 Median of Two Sorted Arrays Java N/A N/A Hard
33 Search in Rotated Sorted Array Java N/A N/A Medium
34 Find First and Last Position of Element in Sorted Array Java O(logn) O(1) Medium
35 Search Insert Position Java N/A N/A Easy View discussion on leetcode
69 Sqrt(x) Java N/A N/A Easy
74 Search a 2D Matrix Java N/A N/A Medium View discussion on leetcode
153 Find Minimum in Rotated Sorted Array Java N/A N/A Medium
162 Find Peak Element Java N/A N/A Medium
240 Search a 2D Matrix II Java N/A N/A Medium
268 Missing Number Java N/A N/A Easy
278 First Bad Version Java O(logn) O(1) Easy View discussion on leetcode
287 Find the Duplicate Number Java N/A N/A Medium
300 Longest Increasing Subsequence Java N/A N/A Medium
350 Intersection of Two Arrays II Java N/A N/A Easy
367 Valid Perfect Square Java N/A N/A Easy
374 Guess Number Higher or Lower Java O(logn) O(1) Easy
441 Arranging Coins Java O(logn) O(1) Easy
450 Delete Node in a BST Java N/A N/A Medium
633 Sum of Square Numbers Java O(n) O(1) Medium
704 Binary Search Java, Python, C#, JavaScript, TypeScript O(logn) O(1) Easy
744 Find Smallest Letter Greater Than Target Java N/A N/A Easy
852 Peak Index in a Mountain Array Java O(logn) O(1) Easy
875 Koko Eating Bananas Java N/A N/A Medium
1004 Max Consecutive Ones III Java O(N + k) O(1) Medium
1337 The K Weakest Rows in a Matrix Java O(nlogm) O(n) Easy View discussion on leetcode
1346 Check If N and Its Double Exist Java N/A N/A Easy
1351 Count Negative Numbers in a Sorted Matrix Java N/A N/A Easy
1385 Find the Distance Value Between Two Arrays Java N/A N/A Easy
1539 Kth Missing Positive Number Java O(logn) O(n) Easy
1608 Special Array With X Elements Greater Than or Equal X Java O(nlogn) O(1) Easy View discussion on leetcode
1855 Maximum Distance Between a Pair of Values Java N/A N/A Medium
2300 Successful Pairs of Spells and Potions Java N/A N/A Medium

Binary Tree

# Title Solution Time Space Difficulty Note
94 Binary Tree Inorder Traversal Java N/A N/A Easy
98 Validate Binary Search Tree Java N/A N/A Medium
100 Same Tree Java N/A N/A Easy
101 Symmetric Tree Java N/A N/A Easy
102 Valid Anagram Java N/A N/A Medium
104 Maximum Depth of Binary Tree Java N/A N/A Easy
105 Construct Binary Tree from Preorder and Inorder Traversal Java N/A N/A Medium
108 Convert Sorted Array to Binary Search Tree Java N/A N/A Easy
110 Balanced Binary Tree Java N/A N/A Easy
111 Minimum Depth of Binary Tree Java N/A N/A Easy
114 Flatten Binary Tree to Linked List Java N/A N/A Medium
116 Populating Next Right Pointers in Each Node Java N/A N/A Medium
124 Binary Tree Maximum Path Sum Java N/A N/A Hard
144 Binary Tree Preorder Traversal Java N/A N/A Easy
145 Binary Tree Preorder Traversal Java N/A N/A Easy
199 Binary Tree Right Side View Java N/A N/A Medium
226 Invert Binary Tree Java N/A N/A Easy
230 Kth Smallest Element in a BST Java N/A N/A Medium
235 Lowest Common Ancestor of a Binary Search Tree Java O(logn) O(logn) Medium View discussion on leetcode
236 Lowest Common Ancestor of a Binary Tree Java N/A N/A Medium
257 Binary Tree Paths Java N/A N/A Easy
404 Sum of Left Leaves Java N/A N/A Easy
437 Path Sum III Java N/A N/A Medium
450 Delete Node in a BST Java N/A N/A Medium
543 Diameter of Binary Tree Java N/A N/A Easy
617 Merge Two Binary Trees Java N/A N/A Easy
653 Two Sum IV - Input is a BST Java N/A N/A Easy
700 Search in a Binary Search Tree Java N/A N/A Easy
701 Insert into a Binary Search Tree Java N/A N/A Medium
872 Leaf Similar Trees Java N/A N/A Easy
1161 Maximum Level Sum of a Binary Tree Java N/A N/A Medium
1372 Longest ZigZag Path in a Binary Tree Java N/A N/A Medium
1448 Count Good Nodes in Binary Tree Java N/A N/A Medium

Hash Table

# Title Solution Time Space Difficulty Note
1 Two Sum Java N/A N/A Easy
3 Longest Substring Without Repeating Characters Java N/A N/A Medium
12 Integer to Roman Java N/A N/A Medium
13 Roman to Integer Java N/A N/A Easy
17 Letter Combinations of a Phone Number Java N/A N/A Medium
36 Valid Sudoku Java O(n2) O(1) Medium View discussion on leetcode
37 Sudoku Solver Java N/A N/A Hard
41 First Missing Positive Java N/A N/A Hard
49 Group Anagrams Java N/A N/A Medium
73 Set Matrix Zeroes Java N/A N/A Medium
76 Minimum Window Substring Java N/A N/A Hard
105 Construct Binary Tree from Preorder and Inorder Traversal Java N/A N/A Medium
128 Longest Consecutive Sequence Java N/A N/A Medium
138 Copy List with Random Pointer Java N/A N/A Medium
139 Word Break Java N/A N/A Medium
141 Linked List Cycle Java N/A N/A Easy
142 Linked List Cycle II Java N/A N/A Medium
146 LRU Cache Java N/A N/A Medium
160 Intersection of Two Linked Lists Java N/A N/A Easy
169 Majority Element Java N/A N/A Easy
202 Happy Number Java O(k∗logn) O(k) Easy View discussion on leetcode
205 Isomorphic Strings Java O(n) O(1) Easy
208 Implement Trie (Prefix Tree) Java N/A N/A Medium
217 Contains Duplicate Java N/A N/A Easy
219 Contains Duplicate II Java O(N) O(N) Easy
242 Valid Anagram Java N/A N/A Easy
268 Missing Number Java N/A N/A Easy
290 Word Pattern Java N/A N/A Easy
347 Top K Frequent Elements Java N/A N/A Medium
350 Intersection of Two Arrays II Java N/A N/A Easy
383 Ransom Note Java N/A N/A Easy
387 First Unique Character in a String Java N/A N/A Easy
389 Find the Difference Java N/A N/A Easy
438 Find All Anagrams in a String Java N/A N/A Medium
560 Subarray Sum Equals K Java N/A N/A Medium
567 Permutation in String Java N/A N/A Medium
653 Two Sum IV - Input is a BST Java N/A N/A Easy
763 Partition Labels Java N/A N/A Medium
1207 Unique Number of Occurrences Java O(N) O(N) Easy
1346 Check If N and Its Double Exist Java N/A N/A Easy
1657 Determine if Two Strings Are Close Java O(N) O(1) Medium
1679 Max Number of K-Sum Pairs Java O(N) O(1) Medium
2215 Find the Difference of Two Arrays Java N/A N/A Easy
2336 Smallest Number in Infinite Set Java N/A N/A Medium
2352 Equal Row and Column Pairs Java O(N^3) O(1) Medium

Depth-First Search

# Title Solution Time Space Difficulty Note
94 Binary Tree Inorder Traversal Java N/A N/A Easy
98 Validate Binary Search Tree Java N/A N/A Medium
100 Same Tree Java N/A N/A Easy
101 Symmetric Tree Java N/A N/A Easy
104 Maximum Depth of Binary Tree Java N/A N/A Easy
110 Balanced Binary Tree Java N/A N/A Easy
111 Minimum Depth of Binary Tree Java N/A N/A Easy
114 Flatten Binary Tree to Linked List Java N/A N/A Medium
116 Populating Next Right Pointers in Each Node Java N/A N/A Medium
124 Binary Tree Maximum Path Sum Java N/A N/A Hard
144 Binary Tree Preorder Traversal Java N/A N/A Easy
145 Binary Tree Preorder Traversal Java N/A N/A Easy
199 Binary Tree Right Side View Java N/A N/A Medium
200 Number of Islands Java N/A N/A Medium
207 Course Schedule Java N/A N/A Medium
226 Invert Binary Tree Java N/A N/A Easy
230 Kth Smallest Element in a BST Java N/A N/A Medium
235 Lowest Common Ancestor of a Binary Search Tree Java O(logn) O(logn) Medium View discussion on leetcode
236 Lowest Common Ancestor of a Binary Tree Java N/A N/A Medium
257 Binary Tree Paths Java N/A N/A Easy
399 Evaluate Division Java N/A N/A Medium
404 Sum of Left Leaves Java N/A N/A Easy
437 Path Sum III Java N/A N/A Medium
543 Diameter of Binary Tree Java N/A N/A Easy
547 Number of Provinces Java N/A N/A Medium
617 Merge Two Binary Trees Java N/A N/A Easy
653 Two Sum IV - Input is a BST Java N/A N/A Easy
695 Max Area of Island Java N/A N/A Medium
733 Flood Fill Java N/A N/A Easy
841 Keys and Rooms Java N/A N/A Medium
872 Leaf Similar Trees Java N/A N/A Easy
1161 Maximum Level Sum of a Binary Tree Java N/A N/A Medium
1372 Longest ZigZag Path in a Binary Tree Java N/A N/A Medium
1448 Count Good Nodes in Binary Tree Java N/A N/A Medium
1466 Reorder Routes to Make All Paths Lead to the City Zero Java O(n) O(n) Medium View discussion on leetcode

Breadth-First Search

# Title Solution Time Space Difficulty Note
100 Same Tree Java N/A N/A Easy
101 Symmetric Tree Java N/A N/A Easy
102 Valid Anagram Java N/A N/A Medium
104 Maximum Depth of Binary Tree Java N/A N/A Easy
111 Minimum Depth of Binary Tree Java N/A N/A Easy
116 Populating Next Right Pointers in Each Node Java N/A N/A Medium
199 Binary Tree Right Side View Java N/A N/A Medium
200 Number of Islands Java N/A N/A Medium
207 Course Schedule Java N/A N/A Medium
226 Invert Binary Tree Java N/A N/A Easy
279 Perfect Squares Java N/A N/A Medium
322 Coin Change Java N/A N/A Medium
399 Evaluate Division Java N/A N/A Medium
404 Sum of Left Leaves Java N/A N/A Easy
542 01 Matrix Java O(nm) O(nm) Medium View discussion on leetcode
547 Number of Provinces Java N/A N/A Medium
617 Merge Two Binary Trees Java N/A N/A Easy
653 Two Sum IV - Input is a BST Java N/A N/A Easy
695 Max Area of Island Java N/A N/A Medium
733 Flood Fill Java N/A N/A Easy
841 Keys and Rooms Java N/A N/A Medium
994 Rotting Oranges Java N/A N/A Medium
1161 Maximum Level Sum of a Binary Tree Java N/A N/A Medium
1448 Count Good Nodes in Binary Tree Java N/A N/A Medium
1466 Reorder Routes to Make All Paths Lead to the City Zero Java O(n) O(n) Medium View discussion on leetcode
1926 Nearest Exit from Entrance in Maze Java N/A N/A Medium

Recursion

# Title Solution Time Space Difficulty Note
2 Add Two Numbers Java N/A N/A Medium
21 Merge Two Sorted Lists Java N/A N/A Easy
24 Swap Nodes in Pairs Java N/A N/A Medium
25 Reverse Nodes in k-Group Java N/A N/A Hard
50 Pow(x, n) Java N/A N/A Medium
203 Remove Linked List Elements Java N/A N/A Easy
206 Reverse Linked List Java O(n) O(1) Easy
231 Power of Two Java N/A N/A Easy
234 Palindrome Linked List Java N/A N/A Easy
326 Power of Three Java O(log3n) O(log3n) Easy View discussion on leetcode
342 Power of Four Java N/A N/A Easy
394 Decode String Java N/A N/A Medium

Array

# Title Solution Time Space Difficulty Note
1 Two Sum Java N/A N/A Easy
4 Median of Two Sorted Arrays Java N/A N/A Hard
11 Container With Most Water Java N/A N/A Medium
15 3Sum Java N/A N/A Medium
16 3Sum Closest Java N/A N/A Medium
18 4Sum Java N/A N/A Medium
26 Remove Duplicates from Sorted Array Java N/A N/A Easy
27 Remove Element Java N/A N/A Easy
31 Next Permutation Java N/A N/A Medium
33 Search in Rotated Sorted Array Java N/A N/A Medium
34 Find First and Last Position of Element in Sorted Array Java O(logn) O(1) Medium
35 Search Insert Position Java N/A N/A Easy View discussion on leetcode
36 Valid Sudoku Java O(n2) O(1) Medium View discussion on leetcode
37 Sudoku Solver Java N/A N/A Hard
39 Combination Sum Java N/A N/A Medium
41 First Missing Positive Java N/A N/A Hard
42 Trapping Rain Water Java N/A N/A Hard
45 Jump Game II Java N/A N/A Medium
48 Rotate Image Java N/A N/A Medium
49 Group Anagrams Java N/A N/A Medium
51 N-Queens Java N/A N/A Hard
53 Maximum Subarray Java N/A N/A Medium
56 Merge Intervals Java N/A N/A Medium
64 Minimum Path Sum Java N/A N/A Medium
66 Plus One Java N/A N/A Easy
73 Set Matrix Zeroes Java N/A N/A Medium
74 Search a 2D Matrix Java N/A N/A Medium View discussion on leetcode
75 Sort Colors Java N/A N/A Medium
78 Subsets Java N/A N/A Medium
79 Word Search Java N/A N/A Medium
84 Largest Rectangle in Histogram Java N/A N/A Hard
105 Construct Binary Tree from Preorder and Inorder Traversal Java N/A N/A Medium
108 Convert Sorted Array to Binary Search Tree Java N/A N/A Easy
118 Pascal's Triangle Java O(n^2) O(n^2) Easy View discussion on leetcode
119 Pascal's Triangle II Java O(n) O(n) Easy View discussion on leetcode
121 Best Time to Buy and Sell Stock Java N/A N/A Easy
128 Longest Consecutive Sequence Java N/A N/A Medium
136 Single Number Java N/A N/A Easy
139 Word Break Java N/A N/A Medium
152 Maximum Product Subarray Java N/A N/A Medium
153 Find Minimum in Rotated Sorted Array Java N/A N/A Medium
162 Find Peak Element Java N/A N/A Medium
167 Two Sum II - Input Array Is Sorted Java O(n) O(1) Medium View discussion on leetcode
169 Majority Element Java N/A N/A Easy
189 Rotate Array Java N/A O(1) Medium View discussion on leetcode
198 House Robber Java O(N) O(N) Medium
200 Number of Islands Java N/A N/A Medium
215 Kth Largest Element in an Array Java N/A N/A Medium
216 Combination Sum III Java N/A N/A Medium
217 Contains Duplicate Java N/A N/A Easy
219 Contains Duplicate II Java O(N) O(N) Easy
228 Summary Ranges Java N/A N/A Easy
238 Product of Array Except Self Java O(N) O(N) Medium
239 Sliding Window Maximum Java O(n) O(k) Hard
240 Search a 2D Matrix II Java N/A N/A Medium
268 Missing Number Java N/A N/A Easy
283 Move Zeroes Java O(n) O(1) Easy View discussion on leetcode
287 Find the Duplicate Number Java N/A N/A Medium
300 Longest Increasing Subsequence Java N/A N/A Medium
322 Coin Change Java N/A N/A Medium
334 Increasing Triplet Subsequence Java O(N) O(1) Medium
347 Top K Frequent Elements Java N/A N/A Medium
350 Intersection of Two Arrays II Java N/A N/A Easy
399 Evaluate Division Java N/A N/A Medium
414 Third Maximum Number Java N/A N/A Easy
416 Partition Equal Subset Sum Java N/A N/A Medium
435 Non-overlapping Intervals Java N/A N/A Medium
452 Minimum Number of Arrows to Burst Balloons Java N/A N/A Medium
455 Assign Cookies Java N/A N/A Easy
542 01 Matrix Java O(nm) O(nm) Medium View discussion on leetcode
560 Subarray Sum Equals K Java N/A N/A Medium
605 Can Place Flowers Java O(N) O(1) Easy
643 Maximum Average Subarray I Java O(N) O(1) Easy
695 Max Area of Island Java N/A N/A Medium
704 Binary Search Java, Python, C#, JavaScript, TypeScript O(logn) O(1) Easy
724 Find Pivot Index Java N/A N/A Easy
733 Flood Fill Java N/A N/A Easy
735 Asteroid Collision Java O(N + k) O(N) Medium
739 Daily Temperatures Java O(N) O(N) Medium
744 Find Smallest Letter Greater Than Target Java N/A N/A Easy
746 Min Cost Climbing Stairs Java N/A N/A Easy
852 Peak Index in a Mountain Array Java O(logn) O(1) Easy
867 Transpose Matrix Java N/A N/A Easy
875 Koko Eating Bananas Java N/A N/A Medium
977 Squares of a Sorted Array Java O(n) O(n) Easy View discussion on leetcode
994 Rotting Oranges Java N/A N/A Medium
1004 Max Consecutive Ones III Java O(N + k) O(1) Medium
1207 Unique Number of Occurrences Java O(N) O(N) Easy
1268 Search Suggestions System Java N/A N/A Medium
1337 The K Weakest Rows in a Matrix Java O(nlogm) O(n) Easy View discussion on leetcode
1346 Check If N and Its Double Exist Java N/A N/A Easy
1351 Count Negative Numbers in a Sorted Matrix Java N/A N/A Easy
1385 Find the Distance Value Between Two Arrays Java N/A N/A Easy
1431 Kids With the Greatest Number of Candies Java O(N) O(N) Easy
1480 Running Sum of 1D Array Java N/A N/A Easy
1491 Average Salary Excluding the Minimum and Maximum Salary Java N/A N/A Easy
1493 Longest Subarray of 1's After Deleting One Element Java O(N + k) O(1) Medium
1539 Kth Missing Positive Number Java O(logn) O(n) Easy
1572 Matrix Diagonal Sum Java O(n) O(1) Easy View discussion on leetcode
1608 Special Array With X Elements Greater Than or Equal X Java O(nlogn) O(1) Easy View discussion on leetcode
1672 Richest Customer Wealth Java N/A N/A Easy
1679 Max Number of K-Sum Pairs Java O(N) O(1) Medium
1732 Find the Highest Altitude Java O(N) O(1) Easy
1822 Sign of the Product of an Array Java N/A N/A Easy
1855 Maximum Distance Between a Pair of Values Java N/A N/A Medium
1863 Sum of All Subset XOR Totals Java N/A N/A Easy
1926 Nearest Exit from Entrance in Maze Java N/A N/A Medium
2215 Find the Difference of Two Arrays Java N/A N/A Easy
2300 Successful Pairs of Spells and Potions Java N/A N/A Medium
2352 Equal Row and Column Pairs Java O(N^3) O(1) Medium
2462 Total Cost to Hire K Workers Java N/A N/A Medium
2542 Maximum Subsequence Score Java N/A N/A Medium
2660 Determine the Winner of a Bowling Game Java, Python, JavaScript O(n) O(1) Easy View discussion on leetcode

String

# Title Solution Time Space Difficulty Note
3 Longest Substring Without Repeating Characters Java N/A N/A Medium
5 Longest Palindromic Substring Java N/A N/A Medium
12 Integer to Roman Java N/A N/A Medium
13 Roman to Integer Java N/A N/A Easy
14 Longest Common Prefix Java N/A N/A Easy
17 Letter Combinations of a Phone Number Java N/A N/A Medium
20 Valid Parentheses Java N/A N/A Easy
22 Generate Parentheses Java N/A N/A Medium
28 Find the Index of the First Occurrence in a String Java N/A N/A Medium
32 Longest Valid Parentheses Java N/A N/A Hard
49 Group Anagrams Java N/A N/A Medium
58 Length of Last Word Java N/A N/A Easy
67 Add Binary Java N/A N/A Easy
72 Edit Distance Java N/A N/A Medium
76 Minimum Window Substring Java N/A N/A Hard
125 Valid Palindrome Java N/A N/A Easy
131 Palindrome Partitioning Java N/A N/A Medium
139 Word Break Java N/A N/A Medium
151 Reverse Words in a String Java O(N) O(N) Medium
168 Excel Sheet Column Title Java N/A N/A Easy
171 Excel Sheet Column Title Java O(n) O(1) Easy
205 Isomorphic Strings Java O(n) O(1) Easy
208 Implement Trie (Prefix Tree) Java N/A N/A Medium
242 Valid Anagram Java N/A N/A Easy
257 Binary Tree Paths Java N/A N/A Easy
290 Word Pattern Java N/A N/A Easy
344 Reverse String Java O(n) O(1) Easy
345 Reverse Vowels of a String Java O(N/2) O(1) Easy
383 Ransom Note Java N/A N/A Easy
387 First Unique Character in a String Java N/A N/A Easy
389 Find the Difference Java N/A N/A Easy
392 Is Subsequence Java N/A N/A Easy
394 Decode String Java N/A N/A Medium
412 Fizz Buzz Java N/A N/A Easy
438 Find All Anagrams in a String Java N/A N/A Medium
443 String Compression Java O(N^2) O(1) Medium
557 Reverse Words in a String III Java N/A N/A Easy
567 Permutation in String Java N/A N/A Medium
649 Dota2 Senate Java N/A N/A Medium
680 Valid Palindrome II Java N/A N/A Easy
763 Partition Labels Java N/A N/A Medium
784 Letter Case Permutation Java O(2^n) O(2^n) Medium View discussion on leetcode
1143 Longest Common Subsequence Java N/A N/A Medium
1268 Search Suggestions System Java N/A N/A Medium
1456 Maximum Number of Vowels in a Substring of Given Length Java O(N) O(1) Medium
1657 Determine if Two Strings Are Close Java O(N) O(1) Medium
1768 Merge Strings Alternately Java O(N+M) O(1) Easy
2390 Removing Stars From a String Java O(N) O(NlogN) Medium

Linked List

# Title Solution Time Space Difficulty Note
2 Add Two Numbers Java N/A N/A Medium
19 Remove Nth Node From End of List Java N/A N/A Medium
21 Merge Two Sorted Lists Java N/A N/A Easy
23 Merge k Sorted Lists Java N/A N/A Hard
24 Swap Nodes in Pairs Java N/A N/A Medium
25 Reverse Nodes in k-Group Java N/A N/A Hard
83 Remove Duplicates from Sorted List Java N/A N/A Easy
114 Flatten Binary Tree to Linked List Java N/A N/A Medium
116 Populating Next Right Pointers in Each Node Java N/A N/A Medium
138 Copy List with Random Pointer Java N/A N/A Medium
141 Linked List Cycle Java N/A N/A Easy
142 Linked List Cycle II Java N/A N/A Medium
146 LRU Cache Java N/A N/A Medium
148 Sort List Java N/A N/A Medium
160 Intersection of Two Linked Lists Java N/A N/A Easy
206 Reverse Linked List Java O(n) O(1) Easy
234 Palindrome Linked List Java N/A N/A Easy
328 Odd Even Linked List Java O(N) O(N) Medium
876 Middle of the Linked List Java N/A N/A Easy
2095 Delete the Middle Node of a Linked List Java O(N) O(N) Medium
2130 Leaf Similar Trees Java O(N) O(N) Medium

Doubly Linked List

# Title Solution Time Space Difficulty Note
146 LRU Cache Java N/A N/A Medium

Two Pointers

# Title Solution Time Space Difficulty Note
11 Container With Most Water Java N/A N/A Medium
15 3Sum Java N/A N/A Medium
16 3Sum Closest Java N/A N/A Medium
18 4Sum Java N/A N/A Medium
19 Remove Nth Node From End of List Java N/A N/A Medium
26 Remove Duplicates from Sorted Array Java N/A N/A Easy
27 Remove Element Java N/A N/A Easy
28 Find the Index of the First Occurrence in a String Java N/A N/A Medium
31 Next Permutation Java N/A N/A Medium
42 Trapping Rain Water Java N/A N/A Hard
75 Sort Colors Java N/A N/A Medium
125 Valid Palindrome Java N/A N/A Easy
141 Linked List Cycle Java N/A N/A Easy
142 Linked List Cycle II Java N/A N/A Medium
148 Sort List Java N/A N/A Medium
151 Reverse Words in a String Java O(N) O(N) Medium
160 Intersection of Two Linked Lists Java N/A N/A Easy
167 Two Sum II - Input Array Is Sorted Java O(n) O(1) Medium View discussion on leetcode
189 Rotate Array Java N/A O(1) Medium View discussion on leetcode
202 Happy Number Java O(k∗logn) O(k) Easy View discussion on leetcode
203 Remove Linked List Elements Java N/A N/A Easy
234 Palindrome Linked List Java N/A N/A Easy
283 Move Zeroes Java O(n) O(1) Easy View discussion on leetcode
287 Find the Duplicate Number Java N/A N/A Medium
295 Find Median from Data Stream Java N/A N/A Hard
344 Reverse String Java O(n) O(1) Easy
345 Reverse Vowels of a String Java O(N/2) O(1) Easy
350 Intersection of Two Arrays II Java N/A N/A Easy
392 Is Subsequence Java N/A N/A Easy
443 String Compression Java O(N^2) O(1) Medium
455 Assign Cookies Java N/A N/A Easy
557 Reverse Words in a String III Java N/A N/A Easy
567 Permutation in String Java N/A N/A Medium
633 Sum of Square Numbers Java O(n) O(1) Medium
653 Two Sum IV - Input is a BST Java N/A N/A Easy
680 Valid Palindrome II Java N/A N/A Easy
763 Partition Labels Java N/A N/A Medium
876 Middle of the Linked List Java N/A N/A Medium
977 Squares of a Sorted Array Java O(n) O(n) Easy View discussion on leetcode
1346 Check If N and Its Double Exist Java N/A N/A Easy
1385 Find the Distance Value Between Two Arrays Java N/A N/A Easy
1679 Max Number of K-Sum Pairs Java O(N) O(1) Medium
1768 Merge Strings Alternately Java O(N+M) O(1) Easy
1855 Maximum Distance Between a Pair of Values Java N/A N/A Medium
2095 Delete the Middle Node of a Linked List Java O(N) O(N) Medium
2130 Leaf Similar Trees Java O(N) O(N) Medium
2300 Successful Pairs of Spells and Potions Java N/A N/A Medium
2462 Total Cost to Hire K Workers Java N/A N/A Medium

Combinatorics

# Title Solution Time Space Difficulty Note
62 Unique Paths Java N/A N/A Medium View discussion on leetcode
1863 Sum of All Subset XOR Totals Java N/A N/A Easy

Counting

# Title Solution Time Space Difficulty Note
169 Majority Element Java N/A N/A Easy
347 Top K Frequent Elements Java N/A N/A Medium
383 Ransom Note Java N/A N/A Easy
387 First Unique Character in a String Java N/A N/A Easy

Union Find

# Title Solution Time Space Difficulty Note
128 Longest Consecutive Sequence Java N/A N/A Medium
200 Number of Islands Java N/A N/A Medium
399 Evaluate Division Java N/A N/A Medium
547 Number of Provinces Java N/A N/A Medium
695 Max Area of Island Java N/A N/A Medium

Topological Sort

# Title Solution Time Space Difficulty Note
207 Course Schedule Java N/A N/A Medium

Bucket Sort

# Title Solution Time Space Difficulty Note
347 Top K Frequent Elements Java N/A N/A Medium

Merge Sort

# Title Solution Time Space Difficulty Note
23 Merge k Sorted Lists Java N/A N/A Hard
148 Sort List Java N/A N/A Medium

(back to top)

⚡ JavaScript

JS

# Title Solution Time Space Difficulty Note
2618 Check if Object Instance of Class JavaScript N/A N/A Easy
2619 Array Prototype Last JavaScript N/A N/A Easy
2620 Counter JavaScript N/A N/A Easy
2621 Sleep JavaScript N/A N/A Easy
2634 Filter Elements from Array JavaScript N/A N/A Easy
2648 Generate Fibonacci Sequence JavaScript N/A N/A Easy
2665 Counter II JavaScript N/A N/A Easy
2666 Allow One Function Call JavaScript N/A N/A Easy
2667 Create Hello World Function JavaScript N/A N/A Easy
2703 Return Length of Arguments Passed JavaScript N/A N/A Easy
2704 To Be Or Not To Be JavaScript N/A N/A Easy
2724 Sort By JavaScript N/A N/A Easy
2726 Calculator with Method Chaining JavaScript N/A N/A Easy
2727 Is Object Empty JavaScript N/A N/A Easy

(back to top)

🛄 Database

SQL

# Title Solution Time Space Difficulty Note
----- ---------------- --------------- --------------- --------------- ------------- --------------

(back to top)

🔑 Shell

Shell Script

# Title Solution Time Space Difficulty Note
----- ---------------- --------------- --------------- --------------- ------------- --------------

(back to top)

🔥 Concurrency

Concurrency

# Title Solution Time Space Difficulty Note
----- ---------------- --------------- --------------- --------------- ------------- --------------

(back to top)

📜 Useful Information

References

Big O Notation

Big O notation is used to classify algorithms according to how their running time or space requirements grow as the input size grows. On the chart below you may find most common orders of growth of algorithms specified in Big O notation.

Big O graphs

Source: Big O Cheat Sheet.

Below is the list of some of the most used Big O notations and their performance comparisons against different sizes of the input data.

Big O Notation Type Computations for 10 elements Computations for 100 elements Computations for 1000 elements
O(1) Constant 1 1 1
O(log N) Logarithmic 3 6 9
O(N) Linear 10 100 1000
O(N log N) n log(n) 30 600 9000
O(N^2) Quadratic 100 10000 1000000
O(2^N) Exponential 1024 1.26e+29 1.07e+301
O(N!) Factorial 3628800 9.3e+157 4.02e+2567

Data Structure Operations Complexity

Data Structure Access Search Insertion Deletion Comments
Array 1 n n n
Stack n n 1 1
Queue n n 1 1
Linked List n n 1 n
Hash Table - n n n In case of perfect hash function costs would be O(1)
Binary Search Tree n n n n In case of balanced tree costs would be O(log(n))
B-Tree log(n) log(n) log(n) log(n)
Red-Black Tree log(n) log(n) log(n) log(n)
AVL Tree log(n) log(n) log(n) log(n)
Bloom Filter - 1 1 - False positives are possible while searching

Array Sorting Algorithms Complexity

Name Best Average Worst Memory Stable Comments
Bubble sort n n2 n2 1 Yes
Insertion sort n n2 n2 1 Yes
Selection sort n2 n2 n2 1 No
Heap sort n log(n) n log(n) n log(n) 1 No
Merge sort n log(n) n log(n) n log(n) n Yes
Quick sort n log(n) n log(n) n2 log(n) No Quicksort is usually done in-place with O(log(n)) stack space
Shell sort n log(n) depends on gap sequence n (log(n))2 1 No
Counting sort n + r n + r n + r n + r Yes r - biggest number in array
Radix sort n * k n * k n * k n + k Yes k - length of longest key

(back to top)

👋 Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

⚠️ License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

🤝 Author

@lironabutbul

A few more projects and study materials about Computer-Science on ladunjexa.

Get in touch - on LinkedIn - on Telegram

(back to top)

About

📑 LeetCode problems' Algorithms and Solutions implemented in common PL with explanations and links to further readings.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages