Skip to content

Solution to LeetCode Problems in Python and Golang 🎯

License

Notifications You must be signed in to change notification settings

Pratul1997/LeetCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode License Languages

If you ❤️ this project, please leave me a star ⭐, and contribute to the project by forking the Repository.

About Author
  • I am Final year student from LNMIIT Jaipur
  • Looking for Job Opportunities 🏢
  • Can be reached out at, 📧 : pratulkumar1997@gmail.com

Solution to LeetCode Problems in Python

ALGORITHMS

S.No. Title Solutions Time Space Difficulty Related Topics
1 Two Sum Solution ⭐ O(n) O(n) Easy Array, Hash Table
2 Add Two Numbers Solution O(n) O(1) Medium Linked List, Math
3 Longest Substring Without Repeating Characters Solution ⭐ O(n) O(n) Medium Hash Table, Two Pointers, String
7 Reverse Integer Solution ⭐ O(n) O(1) Easy Math
9 Palindrome Number Solution O(1) O(1) Easy Math
11 Container With Most Water Solution ⭐ O(n) O(1) Medium Array, Two Pointers
12 Integer to Roman Solution ⭐ O(1) O(1) Medium Math, String
13 Roman to Integer Solution ⭐ O(n) O(1) Medium Math, String
14 Longest Common Prefix Solution O(n^2) O(1) Easy String
19 Remove Nth Node From End of List Solution O(n) O(1) Medium Linked List, Two Pointers
20 Valid Parentheses Solution O(n) O(n) Easy String, Stack
21 Merge Two Sorted Lists Solution O(n) O(n) Easy Linked List
22 Generate Parentheses Solution O(n^2) O(n!) Medium String, Backtracking
24 Swap Nodes in Pairs Solution O(n) O(1) Medium Linked List
25 Reverse Nodes in k-Group Solution O(n) O(1) Hard Linked List
26 Remove Duplicates from Sorted Array Solution O(n) O(1) Easy Array, Two Pointers
27 Remove Element Solution O(n) O(1) Easy Array, Two Pointers
28 Implement strStr() Solution O(n) O(1) Easy Two Pointers, String
35 Search Insert Position Solution O(n) O(1) Easy Array, Binary Search
38 Count and Say Solution O(n^2) O(1) Easy String
43 Multiply Strings Solution O(1) O(1) Medium Math, String
50 Pow(x,n) Solution O(logn) O(1) Medium Math, Binary Search
53 Maximum Subarray Solution O(n) O(1) Easy Array, Divide and Conquer, Dynamic Programming
61 Plus One Solution O(n) O(1) Easy Array, Math
65 Valid Number Solution O(1) O(1) Hard Math, String
69 Sqrt(x) Solution O(logn) O(1) Easy Math, Binary Search
70 Climbing Stairs Solution O(n!) O(1) Easy Dynamic Programming
73 Set Matrix Zeroes Solution O(n^2) O(1) Medium Array
78 Subsets Solution O(n^2) O(n^2) Medium Array, Backtracking, Bit Manipulation
80 Remove Duplicates from Sorted Array II Solution O(n) O(1) Medium Array, Two Pointers
83 Remove Duplicates from Sorted List Solution O(n) O(1) Easy Linked List
89 Gray Code Solution O(n^2) O(n) Medium Backtracking
118 Pascal's Triangle Solution O(n^2) O(1) Easy Array
119 Pascal's Triangle II Solution O(n^2) O(k) Easy Array
121 Best Time to Buy and Sell Stock Solution O(n) O(1) Easy Array, Dynamic Programming
122 Best Time to Buy and Sell Stock II Solution O(n) O(1) Easy Array, Greedy
125 Valid Palindrome Solution O(1) O(1) Easy Two Pointers, String
136 Single Number Solution O(n) O(1) Easy Hash Table, Bit Manipulation
141 Linked List Cycle Solution O(n) O(1) Easy Linked List, Two Pointers
142 Linked List Cycle II Solution O(n) O(n) Medium Linked List, Two Pointers
160 Intersection of Two Linked Lists Solution O(n) O(n) Easy Linked List
167 Two Sum II - Input array is sorted Solution O(n) O(1) Easy Array, Two Pointers, Binary Search
169 Majority Element Solution O(n) O(1) Easy Array, Divide and Conquer, Bit Manipulation
172 Factorial Trailing Zeroes Solution O(n) O(1) Easy Math
189 Rotate Array Solution O(1) O(1) Easy Array
203 Remove Linked List Elements Solution O(n) O(1) Easy Linked List
204 Count Primes Solution O(n) O(n) Easy Hash Table, Math
206 Reverse Linked List Solution O(n) O(n) Easy Linked List
217 Contains Duplicate Solution O(n) O(n) Easy Array, Hash Table
219 Contains Duplicate II Solution O(n) O(n) Easy Array, Hash Table
231 Power of Two Solution O(1) O(1) Easy Math, Bit Manipulation
234 Palindrome Linked List Solution O(n) O(n) Easy Linked List, Two Pointers
237 Delete Node in a Linked List Solution O(1) O(1) Easy Linked List
242 Valid Anagram Solution O(n) O(n) Easy Hash Table, Sort
268 Missing Number Solution O(n) O(1) Easy Array, Math, Bit Manipulation
283 Move Zeroes Solution O(n) O(1) Easy Array, Two Pointers
287 Find the Duplicate Number Solution O(nlogn) O(1) Easy Array, Two Pointers, Binary Search
326 Power of Three Solution O(logn) O(1) Easy Math
328 Odd Even Linked List Solution O(n) O(1) Medium Linked List
344 Reverse String Solution O(1) O(1) Easy String, Two Pointer
345 Reverse Vowels of a String Solution O(n) O(1) Easy Two Pointers, String
349 Intersection of Two Arrays Solution O(1) O(1) Easy Hash Table, Two Pointers, Binary Search, Sort
350 Intersection of Two Arrays II Solution O(nlogn) O(n) Easy Hash Table, Two Pointers, Binary Search, Sort
367 Valid Perfect Square Solution O(n) O(1) Easy Math, Binary Search
383 Ransom Note Solution O(n) O(n) Easy String
389 Find the Difference Solution O(n) O(1) Easy Hash Table, Bit Manipulation
392 Is Subsequence Solution O(n^2) O(1) Easy Binary Search, Dynamic Programming, Greedy
412 Fizz Buzz Solution O(n) O(n) Easy Array
413 Arithmetic Slices Solution O(n) O(n) Medium Math, Dynamic Programming
415 Add Strings Solution O(n) O(n) Easy String
441 Arranging Coins Solution O(1) O(1) Easy Math, Binary Search
443 String Compression Solution O(n^2) O(1) Easy String
445 Add Two Numbers II Solution O(n) O(n) Medium Linked List
448 Find All Numbers Disappeared in an Array Solution O(n) O(n) Easy Array
461 Hamming Distance Solution O(n) O(1) Easy Bit Manipulation
476 Number Complement Solution O(n) O(n) Easy Bit Manipulation
485 Max Consecutive Ones Solution O(n) O(1) Easy Array
500 Keyboard Row Solution O(n) O(n) Easy Hash Table
504 Base 7 Solution O(n) O(n) Easy Math
507 Perfect Number Solution O(logn) O(1) Easy Math
509 Fibonacci Number Solution O(n) O(1) Easy Array
535 Encode and Decode TinyURL Solution O(1) O(1) Medium String, Math
537 Complex Number Multiplication Solution O(1) O(1) Medium Hash Table, Math
557 Reverse Words in a String Solution O(n) O(1) Easy String
561 Array Partition I Solution O(n) O(1) Easy Array
566 Reshape the Matrix Solution O(n) O(n^2) Easy Array
581 Shortest Unsorted Continuous Subarray Solution O(n) O(1) Easy Array
599 Minimum Index Sum of Two Lists Solution O(n) O(n) Easy Hash Table
628 Maximum Product of Three Numbers Solution O(nlogn) O(1) Easy Array, Math
633 Sum of Square Numbers Solution O(logn) O(1) Easy Math
645 Set Mismatch Solution O(1) O(n) Easy Hash Table, Math
693 Binary Number with Alternating Bits Solution O(n) O(1) Easy Bit Manipulation
697 Degree of an Array Solution O(n) O(n) Easy Array
804 Unique Morse Code Words Solution O(n^2) O(n) Easy String
832 Flipping an Image Solution O(n^2) O(1) Easy Array
852 Peak Index in a Mountain Array Solution O(n) O(1) Easy Binary Search
856 Score of Parentheses Solution O(n) O(n) Medium String, Stack
860 Lemonade Change Solution O(n) O(1) Easy Greedy
867 Transpose Matrix Solution O(n^2) O(n^2) Easy Array
868 Binary Gap Solution O(n) O(1) Easy Math
876 Middle of the Linked List Solution O(n) O(1) Easy Linked List
884 Uncommon Words from Two Sentences Solution O(n) O(n) Easy Hash Table
888 Fair Candy Swap Solution O(n) O(n) Easy Array
890 Find and Replace Pattern Solution O(n^2) O(n) Medium String
896 Monotonic Array Solution O(n) O(1) Easy Array
905 Sort Array By Parity Solution O(n) O(n) Easy Array
914 X of a Kind in a Deck of Cards Solution O(n^2) O(n) Easy String, Math
917 Reverse Only Letters Solution O(n) O(n) Easy String
921 Minimum Add to Make Parentheses Valid Solution O(n) O(n) Medium Stack, Greedy
922 Sort Array By Parity II Solution O(n) O(n) Easy Array, Sort
929 Unique Email Addresses Solution O(n) O(n) Easy String
941 Valid Mountain Array Solution O(n) O(1) Easy Array
944 Delete Columns to Make Sorted Solution O(n) O(1) Easy Greedy
950 Reveal Cards In Increasing Order Solution O(n) O(n) Medium Array
961 N-Repeated Element in Size 2N Array Solution O(n) O(n) Easy Hash Table

DATABASE

S.No. Title Solutions Difficulty
595 Big Countries Solution Easy