Skip to content

Fettes/Coding-Exercise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arrays and Strings  Programs  Update 

Easy  Medium  Hard

Array

ID Title Solution Difficulty Similar Questions
#0001 Two Sum View Easy 3Sum, Two Sum II, Two Sum III, Subarray Sum Equals K, Two Sum IV, Two Sum Less Than K
#0003 Longest Substring Without Repeating Characters View Medium Longest Substring with At Most Two Distinct Characters, Longest Substring with At Most K Distinct Characters, Subarrays with K Different Integers
#0005 Longest Palindromic Substring View Medium Shortest Palindrome, Palindrome Permutation, Palindrome Pairs, Longest Palindromic Subsequence, Palindromic Substrings
#0007 Reverse Integer View Easy String to Integer (atoi), Reverse Bits
#0011 Container With Most Water View Meidum Trapping Rain Water
#0015 3Sum View Medium Two Sum, 3Sum Closest, 3Sum Smaller
#0016 3Sum Closest View Medium 3Sum, 3Sum Smaller
#0027 Remove Element View Easy Remove Duplicates from Sorted Array, Remove Linked List Elements, Move Zeroes
#0031 Next Permutation View Medium Permutations, Permutations II, Permutation Sequence, Palindrome Permutation II
#0088 Merge Sorted Array View Easy Merge Two Sorted Lists, Squares of a Sorted Array, Interval List Intersections
#0165 Compare Version Numbers View Medium
#0167 Two Sum II View Easy Two Sum, Two Sum IV, Two Sum Less Than K
#0170 Two Sum III View Easy Two Sum, Unique Word Abbreviation, Two Sum IV
#0189 Rotate Array View Easy Rotate List, Reverse Words in a String II
#0238 Product of Array Except Self View Medium Trapping Rain Water, Maximum Product Subarray, Paint House II
#0259 3Sum Smaller View Medium 3Sum, 3Sum Closest, Valid Triangle Number, Two Sum Less Than K
#0268 Missing Number View Easy First Missing Positive, Single Number, Find the Duplicate Number, Couples Holding Hands
#0274 H-z View Medium H-Index II
#0283 Move Zeroes View Easy Remove Element
#0380 Insert Delete GetRandom O(1) View Medium Insert Delete GetRandom O(1) - Duplicates allowed
#0381 Insert Delete GetRandom O(1) - Duplicates allowed View Hard Insert Delete GetRandom O(1)
#0485 Max Consecutive Ones View Easy Max Consecutive Ones II, Max Consecutive Ones III, Consecutive Characters
#0487 Max Consecutive Ones II View Medium Max Consecutive Ones, Max Consecutive Ones III
#0560 Subarray Sum Equals K View Medium Two Sum, Continuous Subarray Sum, Subarray Product Less Than K, Find Pivot Index, Subarray Sums Divisible by K
#0628 Maximum Product of Three Numbers View Maximum Product Subarray
#1099 Two Sum Less Than K View Easy Two Sum, Two Sum II, 3Sum Smaller, Subarray Product Less Than K

# 0442 | Find All Duplicates in an Array | View | Medium ||| 1437 | Check If All 1's Are at Least Length K Places Away | View | Medium | 0706 | Design Hash Map | View | Easy ||| 0705 | Design Hash Set | View | Easy ||| 1475 | Final Prices With a Special Discount in a Shop | View | Easy ||| 1277 | Count Square Submatrices with All Ones | View | Medium ||| 1475 | Final Prices With a Special Discount in a Shop | View | Easy ||| 0287 | Find the Duplicate Number | View | Medium ||| 1481 | Least Number of Unique Integers after K Removals | View | Medium ||| 0004 | Median of Two Sorted Arrays | View | Hard ||| 0918 | Maximum Sum Circular Subarray | View | Medium ||| 0496 | Next Greater Element I | View | Easy ||| 0503 | Next Greater Element II | View | Medium ||| 0556 | Next Greater Element III | View | Medium ||| 1338 | Reduce Array Size to The Half | View | Medium ||| 0905 | Sort Array By Parity | View | Easy ||| 0922 | Sort Array By Parity II | View | Easy ||| 1476 | Subrectangle Queries | View | Medium ||| 1471 | The k Strongest Values in an Array | View | Medium ||| 0941 | Valid Mountain Array | View | Medium |||

BFS (Breadth First Search)

ID Title Solution Difficulty Similar Questions
#0102 Binary Tree Level Order Traversal View Medium Zigzag Level Traversal, Level Order Traversal II, Vertical Order Traversal, N-ary Level Order Traversal
#0126 Word Ladder II View Hard Word Ladder
#0127 Word Ladder View Medium Word Ladder II, Minimum Genetic Mutation
#0200 Number of Islands View Medium Surrounded Regions, Walls and Gates, Number of Islands II, Number of Connected Components in an Undirected Graph, Number of Distinct Islands, Max Area of Island
#0286 Walls and Gates View Medium Surrounded Regions, Number of Islands, Shortest Distance from All Buildings, Robot Room Cleaner, Rotting Oranges
#0433 Minimum Genetic Mutation View Medium Word Ladder
#0505 The Maze II View Medium The Maze, The Maze III
#0515 Find Largest Value in Each Tree Row View Medium
#0733 Flood Fill View Easy Island Perimeter
#0818 Race Car View Hard
#0994 Rotting Oranges View Medium Walls and Gates

Binary Search

ID Title Solution Difficulty Similar Questions
#0004 Median of Two Sorted Arrays View Hard
#0033 Search in Rotated Sorted Array View Medium Search in Rotated Sorted Array II, Find Minimum in Rotated Sorted Array
#0034 Find First and Last Position of Element in Sorted Array View Medium First Bad Version
#0069 Sqrt(x) View Easy Pow(x, n), Valid Perfect Square
#0074 Search a 2D Matrix View Medium Search a 2D Matrix II
#0081 Search in Rotated Sorted Array II View Medium Search in Rotated Sorted Array
#0153 Find Minimum in Rotated Sorted Array View Medium Search in Rotated Sorted Array, Find Minimum in Rotated Sorted Array II
#0154 Find Minimum in Rotated Sorted Array II View Hard Find Minimum in Rotated Sorted Array
#0162 Find Peak Element View Medium Peak Index in a Mountain Array
#0240 Search a 2D Matrix II View Medium Search a 2D Matrix
#0278 First Bad Version View Easy Find First and Last Position of Element in Sorted Array, Search Insert Position, Guess Number Higher or Lower
#0367 Valid Perfect Square View Easy Sqrt(x), Sum of Square Numbers
#0374 Guess Number Higher or Lower View Easy First Bad Version, Guess Number Higher or Lower II, Find K Closest Elements
#0744 Find Smallest Letter Greater Than Target View Easy
#0852 Peak Index in a Mountain Array View Easy Find Peak Element, Find in Mountain Array
#1095 Find in Mountain Array View Hard Peak Index in a Mountain Array

1482 | Minimum Number of Days to Make m Bouquets | View | Medium ||| 1300 | Sum of Mutated Array Closest to Target | View | Medium |||

DFS (Depth First Search)

ID Title Solution Difficulty Similar Questions
#0037 Sudoku Solver View Hard Valid Sudoku, Unique Paths III
#0130 Surrounded Regions View Medium Number of Islands, Walls and Gates
#0200 Number of Islands View Medium Surrounded Regions, Walls and Gates, Number of Islands II, Number of Connected Components in an Undirected Graph, Number of Distinct Islands, Max Area of Island
#0490 The Maze View Medium The Maze II, The Maze III
#0529 Minesweeper View Medium
1020 Number of Enclaves View Medium

Divide And Conquer

ID Title Solution Difficulty Similar Questions
#0315 Count of Smaller Numbers After Self View Hard Count of Range Sum, Queue Reconstruction by Height, Reverse Pairs, How Many Numbers Are Smaller Than the Current Number
#0327 Count of Range Sum View Hard Count of Smaller Numbers After Self, Reverse Pairs
#0493 Reverse Pairs View Hard Count of Smaller Numbers After Self, Count of Range Sum

DP (Dynamic Programming)

ID Title Solution Difficulty Similar Questions
#0032 Longest Valid Parentheses View Hard Valid Parentheses
#0053 Maximum Subarray View Easy Best Time to Buy and Sell Stock, Maximum Product Subarray, Degree of an Array, Longest Turbulent Subarray
#0062 Unique Paths View Medium Unique Paths II, Minimum Path Sum, Dungeon Game
#0063 Unique Paths II View Medium Unique Paths, Unique Paths III
#0064 Minimum Path Sum View Medium Unique Paths, Dungeon Game, Cherry Pickup
#0070 Climbing Stairs View Easy Fibonacci Number, Min Cost Climbing Stairs, N-th Tribonacci Number
#0072 Edit Distance View Hard One Edit Distance, Delete Operation for Two Strings, Minimum ASCII Delete Sum for Two Strings, Uncrossed Lines
#0091 Decode Ways View Medium Decode Ways II
#0115 Distinct Subsequences View Hard
#0120 Triangle View Medium
#0121 Best Time to Buy and Sell Stock View Easy Maximum Subarray, Best Time to Buy and Sell Stock II, Best Time to Buy and Sell Stock III, Best Time to Buy and Sell Stock IV, Best Time to Buy and Sell Stock with Cooldown
#0122 Best Time to Buy and Sell Stock II View Easy Best Time to Buy and Sell Stock
#0123 Best Time to Buy and Sell Stock III View Hard Best Time to Buy and Sell Stock, Best Time to Buy and Sell Stock II, Best Time to Buy and Sell Stock IV, Maximum Sum of 3 Non-Overlapping Subarrays
#0152 Maximum Product Subarray View Medium Maximum Subarray, House Robber, Product of Array Except Self, Maximum Product of Three Numbers, Subarray Product Less Than K
#0188 Best Time to Buy and Sell Stock IV View Hard Best Time to Buy and Sell Stock, Best Time to Buy and Sell Stock II, Best Time to Buy and Sell Stock III
#0198 House Robber View Easy Maximum Product Subarray, House Robber II, Paint House, Paint Fence, House Robber III, Non-negative Integers without Consecutive Ones, Coin Path, Delete and Earn
#0213 House Robber II View Medium House Robber, Paint House, Paint Fence, House Robber III, Non-negative Integers without Consecutive Ones, Coin Path
#0221 Maximal Square View Medium Maximal Rectangle, Largest Plus Sign
#0279 Perfect Squares View Medium Count Primes, Ugly Number II
#0300 Longest Increasing Subsequence View Medium Increasing Triplet Subsequence, Russian Doll Envelopes, Maximum Length of Pair Chain, Number of Longest Increasing Subsequence, Minimum ASCII Delete Sum for Two Strings
#0309 Best Time to Buy and Sell Stock with Cooldown View Medium Best Time to Buy and Sell Stock, Best Time to Buy and Sell Stock II
#0312 Burst Balloons View Hard Minimum Cost to Merge Stones
#0322 Coin Change View Medium Minimum Cost For Tickets
#0509 Fibonacci Number View Easy Climbing Stairs, Split Array into Fibonacci Sequence, Length of Longest Fibonacci Subsequence, N-th Tribonacci Number
#0647 Palindromic Substrings View Medium Longest Palindromic Substring, Longest Palindromic Subsequence
#0714 Best Time to Buy and Sell Stock with Transaction Fee View Medium Best Time to Buy and Sell Stock II
#0746 Min Cost Climbing Stairs View Easy Climbing Stairs
#0818 Race Car [View]
#0887 Super Egg Drop View Hard
#1143 Longest Common Subsequence View Medium Longest Palindromic Subsequence, Delete Operation for Two Strings, Shortest Common Supersequence
0518 Coin Change 2 View Medium
0338 Counting Bits View Medium
0740 Delete and Earn View Medium
0174 Dungeon Game - Memoization View Hard
0174 Dungeon Game - Tabulation View Hard
0368 Largest Divisble Subset View Medium
0300 Longest Increasing Subsequence View Medium
1048 Longest String Chain View Medium
0978 Longest Turbulent Subarray View Medium
1035 Uncrossed Lines View Medium

Greedy Algorithm

ID Title Solution Difficulty Similar Questions
#0012 Integer to Roman View Medium Roman to Integer, Integer to English Words
#0045 Jump Game II View Hard Jump Game, Jump Game III
#0055 Jump Game View Medium Jump Game II, Jump Game III
#0121 Best Time to Buy and Sell Stock View Easy Maximum Subarray, Best Time to Buy and Sell Stock II, Best Time to Buy and Sell Stock III, Best Time to Buy and Sell Stock IV, Best Time to Buy and Sell Stock with Cooldown
#0122 Best Time to Buy and Sell Stock II View Easy
#0455 Assign Cookies View Easy
#0860 Lemonade Change View Easy Best Time to Buy and Sell Stock, Best Time to Buy and Sell Stock III, Best Time to Buy and Sell Stock IV, Best Time to Buy and Sell Stock with Cooldown, Best Time to Buy and Sell Stock with Transaction Fee
#0874 Walking Robot Simulation View Easy

HashMap

ID Title Solution Difficulty Similar Questions
#0036 Valid Sudoku View Medium Sudoku Solver
#0049 Group Anagrams View Medium Valid Anagram, Group Shifted Strings
#0242 Valid Anagram View Easy Group Anagrams, Palindrome Permutation, Find All Anagrams in a String

Heap

ID Title Solution Difficulty Similar Questions
#0023 Merge k Sorted Lists View Hard Merge Two Sorted Lists, Ugly Number II
#0621 Task Scheduler View Medium Rearrange String k Distance Apart, Reorganize String
#0675 Cut Off Trees for Golf Event View Hard
#1244 Design A Leaderboard View Meidum

Linked List

ID Title Solution Difficulty Similar Questions
#0002 Add Two Numbers View Medium Multiply Strings, Add Binary, Sum of Two Integers, Add Strings, Add Two Numbers II, Add to Array-Form of Integer
#0021 Merge Two Sorted Lists View Easy Merge k Sorted Lists, Merge Sorted Array, Sort List, Shortest Word Distance II
#0025 Reverse Nodes in k-Group View Hard Swap Nodes in Pairs
#0138 Copy List with Random Pointer View Medium Clone Graph, Clone Binary Tree With Random Pointer, Clone N-ary Tree
#0206 Reverse Linked List View Easy Reverse Linked List II, Binary Tree Upside Down, Palindrome Linked List
0445 Add Two Numbers II View Medium
0707 Design Linked List View Medium
0141 Linked List Cycle View Easy
0142 Linked List Cycle II View Medium
0876 Middle of the Linked List View Easy
0021 Merge Two Sorted Lists View Easy
1019 Next Greater Node In Linked List View Medium
0328 Odd Even Linked List View Medium
0082 Remove Duplicates from Sorted List II View Medium
0061 Rotate List View Medium
0206 Reverse Linked List View Easy
0092 Reverse Linked List II View Medium
0019 Remove Nth Node From End of List View Medium
0024 Swap Nodes in Pairs View Medium

Recursion

ID Title Solution Difficulty Similar Questions
#0017 Letter Combinations of a Phone Number View Medium Generate Parentheses, Combination Sum, Binary Watch
#0022 Generate Parentheses View Medium Letter Combinations of a Phone Number, Valid Parentheses
#0050 Pow(x, n) View Medium Sqrt(x), Super Pow
#0079 Word Search View Medium Word Search II

Strings

ID Title Solution Difficulty Similar Questions
#0003 Longest Substring Without Repeating Characters View Medium Longest Substring with At Most Two Distinct Characters, Longest Substring with At Most K Distinct Characters, Subarrays with K Different Integers
#0008 String to Integer (atoi) View Medium Reverse Integer, Valid Number
#0013 Roman to Integer View Easy Integer to Roman
#0028 Implement strStr() View Easy Shortest Palindrome, Repeated Substring Pattern
#0048 Rotate Image View Medium
#0058 Length of Last Word View Easy
#0273 Integer to English Words View Hard Integer to Roman
#0387 First Unique Character in a String View Easy Sort Characters By Frequency
#0541 Reverse String II View Easy Reverse String, Reverse Words in a String III
#0709 To Lower Case View Easy
#0771 Jewels and Stones View Easy
#0819 Most Common Word View Easy
#0937 Reorder Data in Log Files View Easy
1433 Check If a String Can Break Another String View Medium
0028 Implement strStr() - KMP Algorithm View Easy
0028 Implement strStr() - Rabin Karp Algorithm View Easy
0459 Repeated Substring Pattern - KMP Algorithm View Easy
0686 Repeated String Match - KMP Algorithm View Easy
1487 Making File Names Unique View Medium

Sliding Window

# Title Solution Difficulty Similar Questions
#0076 Minimum Window Substring View Hard Substring with Concatenation of All Words, Minimum Size Subarray Sum, Sliding Window Maximum, Permutation in String, Smallest Range Covering Elements from K Lists, Minimum Window Subsequence
#0713 Subarray Product Less Than K View Medium Maximum Product Subarray, Maximum Size Subarray Sum Equals k, Subarray Sum Equals K, Two Sum Less Than K
#1004 Max Consecutive Ones III View Medium Longest Substring with At Most K Distinct Characters, Longest Repeating Character Replacement, Max Consecutive Ones, Max Consecutive Ones II
#1248 Count Number of Nice Subarrays View Medium
0904 Fruit Into Baskets View Medium
1052 Grumpy Bookstore Owner View Medium
1358 Number of Substrings Containing All Three Characters View Medium
1234 Replace the Substring for Balanced String View Medium

Sort

ID Title Solution Difficulty Similar Questions
#0056 Merge Intervals View Medium Insert Interval, Meeting Rooms, Meeting Rooms II, Teemo Attacking, Add Bold Tag in String, Range Module, Employee Free Time, Partition Labels, Interval List Intersections
#0207 Course Schedule View Medium Course Schedule II, Graph Valid Tree, Minimum Height Trees, Course Schedule III
#0210 Course Schedule II View Medium Course Schedule, Alien Dictionary, Minimum Height Trees, Sequence Reconstruction, Course Schedule III
#0215 Kth Largest Element in an Array View Medium Wiggle Sort II, Top K Frequent Elements, Third Maximum Number, Kth Largest Element in a Stream, K Closest Points to Origin
#1122 Relative Sort Array View Easy

Stack

ID Title Solution Difficulty Similar Questions
#0020 Valid Parentheses View Easy Generate Parentheses, Longest Valid Parentheses, Remove Invalid Parentheses, Check If Word Is Valid After Substitutions
#0032 Longest Valid Parentheses View Hard Valid Parentheses
#0042 Trapping Rain Water View Hard Container With Most Water, Product of Array Except Self, Trapping Rain Water II, Pour Water
1381 Design a Stack With Increment Operation View Medium
0146 LRU Cache View Medium
0232 Implement Queue using Stacks View Easy
0155 Min Stack View Easy

Tree

ID Title Solution Difficulty Similar Questions
#0098 Validate Binary Search Tree View Medium Binary Tree Inorder Traversal, Find Mode in Binary Search Tree
#0101 Symmetric Tree View Easy
#0102 Binary Tree Level Order Traversal View Medium Minimum Depth of Binary Tree, Average of Levels in Binary Tree, Cousins in Binary Tree
#0103 Binary Tree Zigzag Level Order Traversal View Medium Binary Tree Level Order Traversal
#0124 Binary Tree Maximum Path Sum View Hard Path Sum, Sum Root to Leaf Numbers, Path Sum IV, Longest Univalue Path, Time Needed to Inform All Employees
#0236 Lowest Common Ancestor of a Binary Tree View Medium Lowest Common Ancestor of a Binary Search Tree, Smallest Common Region
#0515 Find Largest Value in Each Tree Row View Medium
#0543 Diameter of Binary Tree View Easy Diameter of N-Ary Tree
#0653 Two Sum IV View Easy Two Sum, Two Sum II, Two Sum III, Two Sum BSTs
0938 Range Sum of BST View Easy
0617 Merge Two Binary Trees View Easy
0700 Search in a Binary Search Tree View Easy
0129 Sum Root to Leaf Numbers View Medium
0897 Increasing Order Search Tree View Easy
0559 Maximum Depth of N-ary Tree View Easy
0104 Maximum Depth of Binary Tree View Easy
0226 Invert Binary Tree View Easy
0530 Minimum Absolute Difference in BST View Easy
0993 Cousins in Binary Tree View Easy
0783 Minimum Distance Between BST Nodes View Easy
0543 Diameter of Binary Tree View Easy
0110 Balanced Binary Tree View Easy
0222 Count Complete Tree Nodes View Medium
1008 Construct Binary Search Tree from Preorder Traversal View Medium
1448 Count Good Nodes in Binary Tree View Medium
0889 Construct Binary Tree from Preorder and Postorder Traversal View Medium
0429 N-ary Tree Level Order Traversal View Medium
0230 Kth Smallest Element in a BST View Medium
0096 Unique Binary Search Trees View Medium

Trie

ID Title Solution Difficulty Similar Questions
#0208 Implement Trie (Prefix Tree) View Medium Add and Search Word - Data structure design, Design Search Autocomplete System, Replace Words, Implement Magic Dictionary
#0212 Word Search II View Hard Word Search, Unique Paths III

Union Find

ID Title Solution Difficulty Similar Questions
#0130 Surrounded Regions View Medium Number of Islands, Walls and Gates
#0200 Number of Islands View Medium Surrounded Regions, Walls and Gates, Number of Islands II, Number of Connected Components in an Undirected Graph, Number of Distinct Islands, Max Area of Island
#0547 Friend Circles View Medium Number of Connected Components in an Undirected Graph, Robot Return to Origin, Sentence Similarity, Sentence Similarity II, The Earliest Moment When Everyone Become Friends
1319 Number of Operations to Make Network Connected View Medium
0684 Redundant Connection View Medium
0990 Satisfiability of Equality Equations View Medium

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published