This repository holds Kata that i have collected and completed on the Leetcode training platform. It has been useful to work on these kata locally as it allows me to group them and write test cases / store notes.
If you have been granted access to my template repo, you will find the kata template I am replicating for each test here
The list includes a lot of the teamblind.com kata, and i hope to work my way through it.
Algorithms that are associated with manipulating Arrays. Reduce, Map, Filter are your friends here.
- Contains Duplicate
- Duplicate Zeros
- Group Anagrams
- Longest Consecutive Sequence
- Max Consecutive Ones
- Product of Array Except Self
- Top K Frequent Elements
- Two Sum
- Valid Anagram
- Valid Sudoku
"Every you have a problem that is solved by a series of decisions you may have to backtrack to another point and choose something else"
It incrementally builds all candidates for the solution and abandon's / backtracks when the solution is not valid. It is a general graph search.
- Subsets
- Combination Sum
- Permutations
- Subsets 2
- Combination Sum 2
- Palindrome Partitioning
- Letter Combination of a Phone Number
- N Queens
Binary search is a fast search algorithm that finds the position of a target value within a sorted array by repeatedly dividing the search parameter in half.
- Binary Search
- Find Minimum in Rotated Sorted Array
- Koko Eating Bananas
- Median of Two Sorted Arrays
- Search a 2D Matrix
- Search in Rotated Sorted Array
- Time Based Key Value Store
- Single Number
- Number of 1 Bits
- Counting Bits
- Reverse Bits
- Missing Number
- Sum of To Integers
- Reverse Integer
https://leetcode.com/discuss/study-guide/458695/Dynamic-Programming-Patterns
- Climbing Stairs
- Combination Sum 4
- Coin Change
- Decode Ways
- House Robber
- House Robber II
- Jump Game
- Min Cost Climbing Stairs
- Palindromic Substrings
- Longest Palindromic Substring
- Maximum Product Sub Array
- Word Break
- Longest Increasing Subsequence
- Partition Equal Subset Sum
- Unique Paths
- Longest Common Subsequence
- Best Time To Buy And Sell Stock With A Cooldown
- Coin Change 2
- Target Sum
- Interleaving String
- Longest Increasing Path In A Matrix
- Distinct Subsequence
- Edit Distance
- Burst Balloons
- Regular Expression Matching
Recursion is the backbone of dynamic programming and backtracking.
https://leetcode.com/discuss/study-guide/1733447/become-master-in-recursion
- Clone Graph
- Course Schedule
- Pacific Atlantic Water Flow
- Number of Islands
- Longest Consecutive Sequence
- Graph Valid Tree Leetcode Premium
- Number of Connected Components in an Undirected Graph Leetcode Premium
- Max Area of Island
- Surrounded Regions
- Rotting Oranges
- Walls and Gates
- Course Schedule 2
- Redundant Connection
- Word Ladder
- Reconstruct Itinerary
- Min Cost To Connect All Points
- Network Delay Time
- Swim In Rising Water
- Alien Dictionary
- Cheapest Flights Within K Stops
A greedy algorithm: requires you to internally solve problems (optimally) to solve the higher scope problem. Examples being Dijkstra's algo, where you find the shortest path in a graph and Prim's or Krustal's algo where you find the minimum spanning trees in a graph.
- Maximum Sub Array
- Jump Game 2
- Gas Station
- Hand Of Straights
- Merge Triplets To Form Target Triplet
- Partition Labels
- Valid Parenthesis String
An advanced tree based data structure used primarily for sorting and implementing priority queues
- Insert Interval
- Merge Intervals
- Non-overlapping Intervals
- Meeting Rooms Leetcode Premium
- Meeting Rooms II Leetcode Premium
- Minimum Interval To Include Each Query
- Reverse a Linked List
- Detect Cycle in a Linked List
- Merge Two Sorted Lists
- Merge K Sorted Lists
- Remove Nth Node From End Of List
- Reorder List
- Copy List With Random Pointer
- Add Two Numbers
- Linked List Cycle
- Find The Duplicate Number
- LRU Cache
- Fizzbuzz
- Rotate Image
- Spiral Matrix
- Set Matrix Zeroes
- Happy Number
- Plus One
- Pow(x,n)
- Multiply Strings
- Detect Squares
Think of it like a window sliding across and array of elements, where the window is analysed against a given constraint, i.e. a sub array of elements within a larger array and you update a variable outside the loop.
There are two types of this, one where the window reduces in size and one where it doesn`t
- Best Time to Buy and Sell Stock
- Check N and It's Double Exist
- Maximum SubArray
- Longest Substring Without Repeating Characters
- Longest Repeating Character Replacement
- Minimum Window Substring
- Permutation In String
- Sliding Window Maximum
- Valid Parentheses
- Min Stack
- [] Evaluate Reverse Polish Notation
- [] Generate Parentheses
- [] Daily Temperatures
- [] Car Fleet
- [] Largest Rectangle In Histogram
- Valid Palindrome
- Valid Palindrome
- Two Sum II Input Array Is Sorted
- 3Sum
- Container With Most Water
- Trapping Rain Water
- Palindrome Number
https://leetcode.com/discuss/study-guide/1337373/tree-question-pattern-2021-placement
- Maximum Depth of Binary Tree
- Same Tree
- Invert Binary Tree
- Binary Tree Maximum Path Sum
- Binary Tree Level Order Traversal
- Serialize and Deserialize Binary Tree
- Subtree of Another Tree
- Construct Binary Tree from pre order and in order traversal
- Validate Binary Search Tree
- Kth Smallest Element in a BST
- Lowest Common Ancestor of BST
- Add and Search Word
- Diameter of Binary Tree
- Balanced Binary Tree
- Binary Tree Right Side View
- Count Good Nodes In Binary Tree
- Implement Trie (Prefix Tree)
- Word Search
- Word Search II
- Design And Add Search Words Data
A linear structure with the first in, first out order. Imagine lining up for a ride, those at the front get on first.
- Kth Largest Element In A Stream
- Last Stone Weight
- K Closest Points to Origin
- Kth Largest Element In An Array
- Task Scheduler
- Design Twitter
- Find Median From Data Stream
This is a model for solving coding problems
Process > Example > Data > Algo > Code
- Read the description
- Identify inputs / outputs
- Identify rules / requirements
- Ask clarifying questions
- Examine all examples
- Understand how the input translates to the output
- Identify edge cases: i.e. do we need to handle an empty input?
- Create test cases and confirm outputs
- What kind of data is being dealt with? Strings? Arrays? Objects? Big Numbers etc
- Step by step a process that take you from input to output
- Handle edge cases and valid example inputs
- Code will depend on the algorithm
- Use everything you've gathered so far to write the code
- If there are errors in the output, adjust your algorithm before looking at the code