GithubHelp home page GithubHelp logo

leetcode's Introduction

LeetCode

How to build C++?

  1. Install vcpkg
git clone https://github.com/microsoft/vcpkg
./vcpkg/bootstrap-vcpkg.sh
  1. Install deps gtest
./vcpkg/vcpkg install gtest
  1. Build with cmake
cmake -B build -S . "-DCMAKE_TOOLCHAIN_FILE=$(pwd)/vcpkg/scripts/buildsystems/vcpkg.cmake"
cmake --build build

Problems & Solutions

No. Title Difficulty Solutions Topics
1 Two Sum Easy C++ Go Array Hash Table
2 Add Two Numbers Medium C++ Python Linked List
3 Longest Substring Without Repeating Characters Medium C++ Python String Sliding Window Hash Table
4 Median of Two Sorted Arrays Hard C++ Go Binary Search
5 Longest Palindromic Substring Medium C C++ String Dynamic Programming
6 ZigZag Conversion Medium C String
7 Reverse Integer Easy C++ Python Math
8 String to Integer (atoi) Medium C++ Python Math
9 Palindrome Number Easy C++ Python Math
10 Regular Expression Matching Hard C++
11 Container With Most Water Medium C++
12 Integer to Roman Medium C++
13 Roman to Integer Easy C++ Math
14 Longest Common Prefix Easy C++ String
15 3Sum Medium C C++ Array Two Pointers Sorting
16 3Sum Closest Medium C++
17 Letter Combinations of a Phone Number Medium C++
18 4Sum Medium C++
19 Remove Nth Node From End of List Medium C++ Two Pointers
20 Valid Parentheses Easy C++ Python String Stack
21 Merge Two Sorted Lists Easy C Python3 Linked List
22 Generate Parentheses Medium C++
23 Merge k Sorted Lists Hard C++ Sorting Priority Queue
24 Swap Nodes in Pairs Medium C++ Linked List
25 Reverse Nodes in k-Group Hard C++ Python3 Linked List Recursion
26 Remove Duplicates from Sorted Array Easy C++ Python Array Two Pointers
27 Remove Element Easy Python Array Two Pointers
28 Implement strStr() Easy C++ String KMP
29 Divide Two Integers Medium C++
30 Substring with Concatenation of All Words Hard C++ Hash Table
31 Next Permutation Medium C++ Array
32 Longest Valid Parentheses Hard C++ Stack
33 Search in Rotated Sorted Array Medium C++ Go Array Binary Search
34 Find First and Last Position of Element in Sorted Array Medium C++
35 Search Insert Position Easy C++ Array Binary Search
36 Valid Sudoku Medium C++ Hash Table
38 Count and Say Easy C++ String
39 Combination Sum Medium C++
40 Combination Sum II Medium C++
41 First Missing Positive Hard C++ Array Hash Table
42 Trapping Rain Water Hard C++ Dynamic Programming
43 Multiply Strings Medium C++
44 Wildcard Matching Hard C++ Backtracking
46 Permutations Medium C++ DFS
47 Permutations II Medium C++ DFS
48 Rotate Image Medium C++ Array
49 Group Anagrams Medium C++ String
50 Pow(x, n) Medium C++ Binary Search
53 Maximum Subarray Medium C++ Array
54 Spiral Matrix Medium C++ Array
55 Jump Game Medium C++ Dynamic Programming
56 Merge Intervals Medium C++ Array Sorting
57 Insert Interval Medium C++ Array
58 Length of Last Word Easy C++ String
59 Spiral Matrix II Medium C++ Array
60 Permutation Sequence Medium C++
61 Rotate List Medium C++ Python3 Linked List
62 Unique Paths Medium C C++ Dynamic Programming
63 Unique Paths II Medium C++ Dynamic Programming
64 Minimum Path Sum Medium C++ Dynamic Programming
66 Plus One Easy C++ Array
67 Add Binary Easy C++ String Bit Manipulation
69 Sqrt(x) Easy C++ Binary search
70 Climbing Stairs Easy C++ Dynamic Programming
71 Simplify Path Medium C++
72 Edit Distance Hard C++ Dynamic Programming
73 Set Matrix Zeroes Medium C++ Array
74 Search a 2D Matrix Medium C++ Binary Search
75 Sort Colors Medium C++ Array Two Pointers
77 Combinations Medium C++
78 Subsets Medium C++
79 Word Search Medium C++ Backtracking
80 Remove Duplicates from Sorted Array II Medium C++ Array
81 Search in Rotated Sorted Array II Medium C++
82 Remove Duplicates from Sorted List II Medium C++ Python3 Linked List Two Pointers
83 Remove Duplicates from Sorted List Easy C++
86 Partition List Medium C++
88 Merge Sorted Array Easy C++ Two Pointers
89 Gray Code Medium C++ Bit Manipulation
90 Subsets II Medium C++
91 Decode Ways Medium C++ Dynamic Programming
92 Reverse Linked List II Medium C++ Linked List
93 Restore IP Addresses Medium C++ DFS
94 Binary Tree Inorder Traversal Medium C++ Go Tree Stack
95 Unique Binary Search Trees II Medium C++ Tree
96 Unique Binary Search Trees Medium C++ Dynamic Programming
98 Validate Binary Search Tree Medium C++ DFS Inorder Traversal
99 Recover Binary Search Tree Medium C++ DFS Inorder Traversal
100 Same Tree Easy C++ Tree DFS BFS
101 Symmtric Tree Easy C++ Tree DFS BFS
102 Binary Tree Level Order Traversal Medium C++ Tree BFS DFS
103 Binary Tree Zigzag Level Order Traversal Medium C++ Tree
104 Maximum Depth of Binary Tree Easy C++ Tree DFS
105 Construct Binary Tree from Preorder and Inorder Traversal Medium C++ Tree DFS
106 Construct Binary Tree from Inorder and Postorder Traversal Medium C++ Tree DFS
107 Binary Tree Level Order Traversal II Easy C++ Tree
108 Convert Sorted Array to Binary Search Tree Easy C++ Tree
109 Convert Sorted List to Binary Search Tree Medium C++ Tree
110 Balanced Binary Tree Easy C++ Tree DFS
111 Minimum Depth of Binary Tree Easy C++ Tree
112 Path Sum Easy C++ Python Tree DFS
113 Path Sum II Medium Python
114 Flatten Binary Tree to Linked List Medium C++ Tree
115 Distinct Subsequences Hard C++ Dynamic Programming
116 Populating Next Right Pointers in Each Node Medium C++ Tree DFS
117 Populating Next Right Pointers in Each Node II Medium C++ Tree BFS DFS
118 Pascal's Triangle Easy C++ Array
119 Pascal's Triangle II Easy C++ Array
120 Triangle Medium C++ Dynamic Programming
121 Best Time to Buy and Sell Stock Easy C++ Array
122 Best Time to Buy and Sell Stock II Easy C++ Array
123 Best Time to Buy and Sell Stock III Hard C++
124 Binary Tree Maximum Path Sum Hard C++ Tree DFS
125 Valid Palindrome Easy C++ String Two Pointers
126 Word Ladder II Hard C++ BFS
127 Word Ladder Medium C++ BFS
128 Longest Consecutive Sequence Medium C++ Array
129 Sum Root to Leaf Numbers Medium C++ DFS
130 Surrounded Regions Medium C++ Union Find
131 Palindrome Partitioning Medium C++ DFS
133 Clone Graph Medium C++ Python3 Hash Table DFS BFS
136 Single Number Easy Python Bit Manipulation
137 Single Number II Medium C++ Bit Manipulation
138 Copy List with Random Pointer Medium C++ Linked List
139 Word Break Medium C++ Dynamic Programming
140 Word Break II Hard C++ DFS Dynamic Programming
141 Linked List Cycle Easy C++ Linked List Two Pointers
142 Linked List Cycle II Medium C++ Hash Table Two Pointers
143 Reorder List Medium C C++ Recursion
144 Binary Tree Preorder Traversal Medium C++ Tree Stack
145 Binary Tree Postorder Traversal Hard C++ Tree Stack
146 LRU Cache Medium C++ Design
147 Insertion Sort List Medium C
148 Sort List Medium C++ Python3 Sorting Merge Sort
149 Max Points on a Line Hard C++ Math
150 Evaluate Reverse Polish Notation Medium C++ Stack
151 Reverse Words in a String Medium C++
152 Maximum Product Subarray Medium C++ Dynamic Programming
153 Find Minimum in Rotated Sorted Array Medium C C++ Binary Search
154 Find Minimum in Rotated Sorted Array II Hard C C++ Binary Search
155 Min Stack Easy C++ Python Stack Design
160 Intersection of Two Linked Lists Easy C++ Two Pointers
162 Find Peak Element Medium C++ Binary Search
163 Missing Ranges Easy C++ Array
164 Maximum Gap Hard C++ Sorting Bucket Sort
165 Compare Version Numbers Medium C++ Python3 String
167 Two Sum II - Input array is sorted Easy C++
168 Excel Sheet Column Title Easy C++ Math
169 Majority Element Easy C++ Array Sorting Hash Table
171 Excel Sheet Column Number Easy C++ Math String
173 Binary Search Tree Iterator Medium C++ Tree Stack
175 Combine Two Tables Easy MySQL Database
176 Second Highest Salary Easy MySQL Database
177 Nth Highest Salary Medium MySQL Database
178 Rank Scores Medium MySQL Database
179 Largest Number Medium Python
189 Rotate Array Easy C Array
197 Rising Temperature Easy MySQL
190 Reverse Bits Easy C++ Bit Manipulation
191 Number of 1 Bits Easy C++ Bit Manipulation
192 Word Frequency Medium Bash
193 Valid Phone Numbers Easy Bash
194 Transpose File Medium Bash
195 Tenth Line Easy Bash
196 Delete Duplicate Emails Easy MySQL
198 House Robber Easy C++ Dynamic Programming
199 Binary Tree Right Side View Medium C++ BFS
200 Number of Islands Medium C++ Union Find
202 Happy Number Easy C++ Go Python3 Hash Table Two Pointers
203 Remove Linked List Elements Easy C++ Linked List
204 Count Primes Easy C++ Math
205 Isomorphic Strings Easy Go Hash Table
206 Reverse Linked List Easy C++ Python3 Linked List Recursion
208 Implement Trie (Prefix Tree) Medium C++ Design Trie
209 Course Schedule Medium C++ DFS Graph
215 Kth Largest Element in an Array Medium C++ Sorting Priority Queue
216 Combination Sum III Medium C++
217 Contains Duplicate Easy C++ Hash Table Sorting
219 Contains Duplicate II Easy C++
220 Contains Duplicate III Medium C++
222 Count Complete Tree Nodes Medium C++ Tree DFS
224 Basic Calculator Hard C++ String Stack
225 Implement Stack using Queues Easy C++ Stack Queue
226 Invert Binary Tree Easy C++ Tree DFS
227 Basic Calculator II Medium C++ String Stack
228 Summary Ranges Easy Python3 Array
230 Kth Smallest Element in a BST Medium C++ Tree BFS
232 Implement Queue using Stacks Easy C++ Stack Queue
234 Palindrome Linked List Medium C++ Linked List Two Pointers
235 Lowest Common Ancestor of a Binary Search Tree Easy C++ Tree DFS
236 Lowest Common Ancestor of a Binary Tree Medium C++ Go Tree DFS
237 Delete Node in a Linked List Easy C++ Linked List
238 Product of Array Except Self Medium C++ Array Prefix Sum
242 Valid Anagram Easy C++ String Hash Table
257 Binary Tree Paths Easy C++
258 Add Digits Easy Python3 Math
263 Ugly Number Easy Python
268 Missing Number Easy C++ Array Math
274 H-Index Medium C++ Sorting
278 First Bad Version Easy C++ Binary Search
283 Move Zeroes Easy C++ Two Pointers
286 Walls and Gates Medium C++ Matrix DFS
287 Find the Duplicate Number Medium C++ Two Pointers
292 Nim Game Easy C++ Brainteaser
295 Find Median from Data Stream Hard C++ Sorting Priority Queue
297 Serialize and Deserialize Binary Tree Hard C++ Tree DFS
300 Longest Increasing Subsequence Medium C++ Dynamic Programming
303 Range Sum Query - Immutable Easy C++ Array
322 Coin Change Medium C++ Dynamic Programming
326 Power of Three Easy C++ Math
328 Odd Even Linked List Medium C++ Linked List
334 Increasing Triplet Subsequence Medium C++
338 Counting Bits Easy C++ Dynamic Programming
344 Reverse String Easy C++ Two Pointers
347 Top K Frequent Elements Medium C++ Hash Table Heap
348 Design Tic-Tac-Toe Medium C++ Matrix
349 Intersection of Two Arrays Easy C++ Hash Table
350 Intersection of Two Arrays II Easy C++ Hash Table
367 Valid Perfect Square Easy C++ Binary Search
371 Sum of Two Integers Easy C++
374 Guess Number Higher or Lower Easy C++ Binary Search
377 Combination Sum IV Medium C++
382 Linked List Random Node Medium C++ Linked List
383 Ransom Note Easy C++ Python3 Hash Table
384 Shuffle an Array Medium C++ Design
386 Lexicographical Numbers Medium C++
387 First Unique Character in a String Easy C++ Hash Table
389 Find the Difference Easy C++ Hash Table Bit Manipulation
392 Is Subsequence Easy C++ Python3 String
397 Integer Replacement Medium C++
404 Sum of Left Leaves Easy C++ Tree
409 Longest Palindrome Easy C++ String Hash Table
410 Split Array Largest Sum Hard C++ Binary Search
412 Fizz Fuzz Easy C++ Math
414 Third Maximum Number Easy C++ Sorting
415 Add Strings Easy C++
429 N-ary Tree Level Order Traversal Medium C++ Tree BFS
430 Flatten a Multilevel Doubly Linked List Medium C++ Linked List
437 Path Sum III Easy C++
442 Find All Duplicates in an Array Medium C++
443 String Compression Easy C++
448 Find All Numbers Disappeared in an Array Easy C++
451 Sort Characters By Frequency Medium C++ Python3 Hash Table Sorting
452 Minimum Number of Arrows to Burst Balloons Medium C++ Python3 Sorting
455 Assign Cookies Easy C++ Sorting Two Pointers
461 Hamming Distance Easy C++ Bit Manipulation
477 Total Hamming Distance Medium C++ Math Bit Manipulation
480 Sliding Window Median Hard C++ Array
485 Max Consecutive Ones Easy C++ Array
487 Max Consecutive Ones II Medium C++ Array Two Pointers
491 Increasing Subsequences Medium C++
501 Find Mode in Binary Search Tree Easy C++
509 Fibonacci Number Easy C++ Array Dynamic Programming
523 Continuous Subarray Sum Medium C++
524 Longest Word in Dictionary through Deleting Medium C++ Sorting Two Pointers
540 Single Element in a Sorted Array Medium C++ Bit Manipulation Binary Search
541 Reverse String II Easy C++
542 01 Matrix Medium C++ BFS Dynamic Programming
543 Diameter of Binary Tree Easy C++ Tree DFS
560 Subarray Sum Equals K Medium C++ Array
563 Binary Tree Tilt Easy C++ Tree DFS
594 Longest Harmonious Subsequence Easy C++ Hash Table
599 Minimum Index Sum of Two Lists Easy C++
623 Add One Row to Tree Medium C++
628 Maximum Product of Three Numbers Easy Go
629 K Inverse Pairs Array Hard C++ Dynamic Programming
645 Set Mismatch Easy C++
653 Two Sum IV - Input is a BST Easy C++
658 Find K Closest Elements Medium C++ Binary Search
662 Maximum Width of Binary Tree Medium C++ Binary Tree BFS
670 Maximum Swap Medium C++ Math
680 Valid Palindrome II Easy C++ String Two Pointers
704 Binary Search Easy C++ Array Binary Search
705 Design HashSet Easy C++ Bit Manipulation Hash Table
706 Design HashMap Easy C++ Array Hash Table
707 Design Linked List Medium C++ Linked List
716 Max Stack Hard C++ Ordered Set Priority Queue
719 Find K-th Smallest Pair Distance Hard C++ Binary Search
733 Flood Fill Easy C++ Array DFS
739 Daily Temperatures Medium C++ Stack
744 Find Smallest Letter Greater Than Target Easy C++ Binary Search
765 Couples Holding Hands Hard C++ Union Find
772 772. Basic Calculator III Hard C++ String Stack
779 K-th Symbol in Grammar Medium C++ Recursion
788 Rotated Digits Easy C++ Dynamic Programming
796 Rotate String Easy C++ String
799 Champagne Tower Medium C++ Dynamic Programming
867 Transpose Matrix Easy C++ Matrix
876 Middle of the Linked List Easy C++ Linked List Two Pointers
899 Orderly Queue Hard C++ Math String
905 Sort Array By Parity Easy C++ Array Two Pointers
912 Sort an Array Medium C++ Array Merge Sort Heap Sort
921 Minimum Add to Make Parentheses Valid Medium C++ String Stack
922 Sort Array By Parity II Easy C++ Array Two Pointers
965 Univalued Binary Tree Easy C++ BFS
973 K Closest Points to Origin Medium C++ Array Sorting Priority Queue
977 Squares of a Sorted Array Easy C++ Array Two Pointers
989 Add to Array-Form of Integer Easy C++ Array Math
993 Cousins in Binary Tree Easy C++ Tree DFS
997 Find the Town Judge Easy C++ Graph
1004 Max Consecutive Ones III Medium C++ Array Two Pointers
1051 Height Checker Easy C++ Array Sorting Counting Sort
1093 Statistics from a Large Sample Medium C++ Array Math
1134 Armstrong Numberhttps://leetcode.com/problems/armstrong-number/ Easy C++ Math
1206 Design Skiplist Hard C++ Linked List
1207 Unique Number of Occurrences Easy C++ Hash Table
1247 Minimum Swaps to Make Strings Equal Medium C++ Math String
1288 Remove Covered Intervals Medium C++ Array Sorting
1365 How Many Numbers Are Smaller Than the Current Numberhttps://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/ Easy C++ Sorting Hash Table
1366 Rank Teams by Votes Medium C++ Array Sorting
1381 Design a Stack With Increment Operation Medium C++ Array Stack
1382 Balance a Binary Search Tree Medium C++ Binary Search Tree
1539 Kth Missing Positive Number Easy C++ Array Hash Table
1641 Count Sorted Vowel Strings Medium C++ Dynamic Programming
1679 Max Number of K-Sum Pairs Medium C++ Hash Table
1720 Decode XORed Array Easy C++ Bit Manipulation
2032 Two Out of Three Easy C++ Set Map
2092 Find All People With Secret Hard C++ Union Find
2108 Find First Palindromic String in the Array Easy C++ Two Pointers
2177 Find Three Consecutive Integers That Sum to a Given Number Medium C++ Math
2293 Min Max Game Easy C++ Array
2864 Maximum Odd Binary Number Easy C++ Math String
2951 Find the Peaks Easy C++ Array

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.