leetcode-study

Leetcode Study Repo

by Adam Owada

Description

Problems and solutions to Leetcode’s Top Interview 150 list. Problems come from Leetcode. Solutions with comments are generated by ChatGPT.

My goal with this repo is to learn and advance my abilities with data structures and algorithms. Lately I’ve noticed that when I solve Leetcode problems, even easy ones, I mistakenly believe I have the best, most optimal solution when in reality there are more efficient and elegant approaches I never thought of.

More alarming is that the approaches and techniques from these optimal solutions are applicable across a wide range of problems, and my solutions feel one-off and narrow. Ultimately this means I have much more to learn. Just getting a solution accepted on Leetcode isn’t enough to maximize growth and learning, I need to see the optimal solution and think about how it can be applied to novel problems.

Table of Contents

Array / String - Study Guide

Merge Sorted Array Easy problem solution
Remove Element Easy problem solution
Remove Duplicates from Sorted Array Easy problem solution
Remove Duplicates from Sorted Array II Medium problem solution
Majority Element Easy problem solution
Rotate Array Medium problem solution
Best Time to Buy and Sell Stock Easy problem solution
Best Time to Buy and Sell Stock II Medium problem solution
Jump Game Medium problem solution
Jump Game II Medium problem solution
H-Index Medium problem solution
Insert Delete GetRandom O(1) Medium problem solution
Product of Array Except Self Medium problem solution
Gas Station Medium problem solution
Candy Hard problem solution
Trapping Rain Water Hard problem solution
Roman to Integer Easy problem solution
Integer to Roman Medium problem solution
Length of Last Word Easy problem solution
Longest Common Prefix Easy problem solution
Reverse Words in a String Medium problem solution
Zigzag Conversion Medium problem solution
Find the Index of the First Occurrence in a String Easy problem solution
Text Justification Hard problem solution

Two Pointers - Study Guide

Valid Palindrome Easy problem solution
Is Subsequence Easy problem solution
Two Sum II - Input Array Is Sorted Medium problem solution
Container With Most Water Medium problem solution
3Sum Medium problem solution

Sliding Window - Study Guide

Minimizing Size Subarray Sum Medium problem solution
Longest Substring Without Repeating Characters Medium problem solution
Substring with Concatenation of All Words Hard problem solution
Minimum Window Substring Hard problem solution

Matrix - Study Guide

Valid Sudoku Medium problem solution
Spiral Matrix Medium problem solution
Rotate Image Medium problem solution
Set Matrix Zeroes Medium problem solution
Game of Life Medium problem solution

Hashmap - Study Guide

Ransom Note Easy problem solution
Isomorphic Strings Easy problem solution
Word Pattern Easy problem solution
Valid Anagram Easy problem solution
Group Anagrams Medium problem solution
Two Sum Easy problem solution
Happy Number Easy problem solution
Contains Duplicate II Easy problem solution
Longest Consecutive Sequence Medium problem solution

Intervals - Study Guide

Summary Ranges Easy problem solution
Merge Intervals Medium problem solution
Insert Interval Medium problem solution
Minimum Number of Arrows to Burst Balloons Medium problem solution

Stack - Study Guide

Valid Parentheses Easy problem solution
Simplify Path Medium problem solution
Min Stack Medium problem solution
Evaluate Reverse Polish Notation Medium problem solution
Basic Calculator Hard problem solution

Linked List

Binary Tree General

Binary Tree BFS

Binary Search Tree

Graph General

Graph BFS

Trie

Backtracking

Divide & Conquer

Kandane’s Algorithm

Heap

Bit Manipulation

Math

1D DP

Multidimensional DP