Skip to content

Akshaya-Amar/LeetCodeSolutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions

Algorithms

My Most Voted Solutions

# Title Explanation Existence Complexity Difficulty Tags
8 String to Integer (atoi) Detailed Explanation On 1st page of Most Voted Category Time - O(n)
Space - O(1)
Medium String
50 Pow(x, n) Detailed Explanation On 1st page of Most Voted Category Time - O(log2(n))
Space - O(1)
Medium Math, Recursion
190 Reverse Bits Detailed Explanation On 1st page of Most Voted Category Time - O(1)
Space - O(1)
Easy Divide and Conquer, Bit Manipuation
989 Add to Array-Form of Integer Detailed Explanation On 1st page of Most Voted Category Time - O(max(n, log10(k)))
Space - O(max(n, log10(k)))
Easy Array, Math
1470 Shuffle the Array Detailed Explanation On 1st page of Most Voted Category Time - O(n)
Space - O(1)
Easy Array
2129 Capitalize the Title Explained Solution On 1st page of Most Voted Category Time - O(n)
Space - O(1)
Easy String

Explained Solutions

# Title Explanation Complexity Difficulty Tags
8 String to Integer (atoi) Detailed Explanation Time - O(n)
Space - O(1)
Medium String
9 Palindrome Number Explained Solution Time - O(log10(n))
Space - O(1)
Easy Math
33 Search in Rotated Sorted Array C++ Explanation
JAVA Explanation
Time - O(log2(n))
Space - O(1)
Medium Array, Binary Search
50 Pow(x, n) Detailed Explanation Time - O(log2(n))
Space - O(1)
Medium Math, Recursion
189 Rotate Array C++ Explanation
JAVA Explanation
Time - O(n)
Space - O(1)
Medium Math, Array, Two Pointers
190 Reverse Bits Detailed Explanation Time - O(1)
Space - O(1)
Easy Divide and Conquer, Bit Manipuation
191 Number of 1 Bits Detailed Explanation Time - O(1)
Space - O(1)
Easy Bit Manipulation
1431 Kids With the Greatest Number of Candies Commented Solution Time - O(n)
Space - O(n)
Easy Array
1470 Shuffle The Array Detailed Explanation Time - O(n)
Space - O(1)
Easy Array
2129 Capitalize the Title Explained Solution Time - O(n)
Space - O(1)
Easy String
2130 Rings and Rods Detailed Explanation Time - O(n)
Space - O(1)
Easy HashTable

Math

# Title Solution Complexity Difficulty Tags
7 Reverse Integer C++
JAVA
Time - O(log10(n))
Space - O(1)
Medium
9 Palindrome Number C++
JAVA
Time - O(log10(n))
Space - O(1)
Easy
50 Pow(x, n) JAVA Time - O(log2(n))
Space - O(1)
Medium Recursion
172 Factorial Trailing Zeroes C++
JAVA
Time - O(log5(n))
Space - O(1)
Medium
231 Power Of Two C++
JAVA
Time - O(1)
Space - O(1)
Easy Bit Manipuation, Recursion
258 Add Digits C++
JAVA
Time - O(1)
Space - O(1)
Easy Simulation, Number Theory
263 Ugly Number C++
JAVA
Time - O(log2(n))
Space - O(1)
Easy
1137 N-th Tribonacci Number C++
JAVA
Time - O(n)
Space - O(1)
Easy Dynamic Programming, Memoization
1281 Subtract the Product and Sum of Digits of an Integer C++
JAVA
Time - O(n)
Space - O(1)
Easy
1342 Number of Steps to Reduce a Number to Zero C++
JAVA
Time - O(log2(n))
Space - O(1)
Easy Bit Manipuation
1551 Minimum Operations to Make Array Equal C++
JAVA
Time - O(1)
Space - O(1)
Medium
1688 Count of Matches in Tournament C++
JAVA
Time - O(1)
Space - O(1)
Easy Simulation

Bit Manipulation

# Title Solution Complexity Difficulty Tags
191 Number of 1 Bits C++
JAVA
Time - O(1)
Space - O(1)
Easy
476 Number Complement C++
JAVA
Time - O(log2(n))
Space - O(1)
Easy
1009 Complement of Base 10 Integer C++
JAVA
Time - O(log2(n))
Space - O(1)
Easy

Array

# Title Solution Complexity Difficulty
1 Two Sum JAVA Time - O(n)
Space - O(n)
Easy
53 Maximum Subarray C++
JAVA
Time - O(n)
Space - O(1)
Easy
80 Remove Duplicates from Sorted Array II C++
JAVA
Time - O(n)
Space - O(1)
Medium
121 Best Time to Buy and Sell Stock C++
JAVA
Time - O(n)
Space - O(1)
Easy
122 Best Time to Buy and Sell Stock II C++
JAVA
Time - O(n)
Space - O(1)
Medium
136 Single Number C++
JAVA
Time - O(n)
Space - O(1)
Easy
162 Find Peak Element C++
JAVA
Time - O(log2(n))
Space - O(1)
Medium
169 Majority Element C++
JAVA
Time - O(n)
Space - O(1)
Easy
189 Rotate Array C++
JAVA,
Explanation
Time - O(n)
Space - O(1)
Medium
228 Summary Ranges JAVA Time - O(n)
Space - O(1)
Easy
229 Majority Element II C++
JAVA
Time - O(n)
Space - O(1)
Medium
287 Find the Duplicate Number JAVA Time - O(n)
Space - O(1)
Medium
413 Arithmetic Slices C++
JAVA
Time - O(n)
Space - O(1)
Medium
414 Third Maximum Number JAVA Time - O(n)
Space - O(1)
Easy
500 Keyboard Row JAVA Time - O(N)
Space - O(n)
Easy
525 Contiguous Array C++
JAVA
Time - O(n)
Space - O(n)
Medium
532 K-diff Pairs in an Array C++
JAVA
Time - O(n)
Space - O(n)
Medium
648 Replace Words JAVA Time - O(m * n)
Space - O(n)
Medium
739 Daily Temperatures JAVA Time - O(n)
Space - O(n)
Medium
746 Min Cost Climbing Stairs C++
JAVA
Time - O(n)
Space - O(1)
Easy
811 Subdomain Visit Count JAVA Time - O(n * m)
Space - O(n)
Medium
881 Boats to Save People JAVA Time - O(n logn)
Space - O(1)
Medium
848 Shifting Letters C++
JAVA
Time - O(n)
Space - O(1)
Medium
941 Valid Mountain Array C++
JAVA
Time - O(n)
Space - O(1)
Easy
1094 Car Pooling C++
JAVA
Time - O(n)
Space - O(n)
Medium
1207 Unique Number of Occurrences JAVA Time - O(n)
Space - O(n)
Easy
1282 Group the People Given the Group Size They Belong To JAVA Time - O(n)
Space - O(n)
Medium
1295 Find Numbers with Even Number of Digits C++
JAVA
Time - O(n)
Space - O(1)
Easy
1365 How Many Numbers Are Smaller Than the Current Number C++
JAVA
Time - O(n + m)
Space - O(m)
Easy
1431 Kids With the Greatest Number of Candies C++
JAVA
Time - O(n)
Space - O(n)
Easy
1441 Build an Array With Stack Operations JAVA Time - O(n)
Space - O(n)
Easy
1464 Maximum Product of Two Elements in an Array C++
JAVA
Time - O(n)
Space - O(1)
Easy
1470 Shuffle The Array C++
JAVA
Time - O(n)
Space - O(1)
Easy
1480 Running Sum of 1d Array C++
JAVA
Time - O(n)
Space - O(1)
Easy
1512 Number of Good Pairs C++
JAVA
Time - O(n)
Space - O(n)
Easy
1550 Three Consecutive Odds C++
JAVA
Time - O(n)
Space - O(1)
Easy
1646 Get Maximum in Generated Array C++
JAVA
Time - O(n)
Space - O(n)
Easy
1662 Check If Two String Arrays are Equivalent C++
JAVA
Time - O(n)
Space - O(1)
Easy
1672 Richest Customer Wealth C++
JAVA
Time - O(m * n)
Space - O(1)
Easy
1720 Decode XORed Array C++
JAVA
Time - O(n)
Space - O(1)
Easy
1748 Sum of Unique Elements C++
JAVA
Time - O(n)
Space - O(m)
Easy
1909 Remove One Element to Make the Array Strictly Increasing C++
JAVA
Time - O(n)
Space - O(1)
Easy
1929 Concatenation of Array C++
JAVA
Time - O(n)
Space - O(1)
Easy
1979 Find Greatest Common Divisor of Array C++
JAVA
Time - O(n)
Space - O(1)
Easy
1980 Find Unique Binary String C++
JAVA
Time - O(n)
Space - O(1)
Medium
2006 Count Number of Pairs With Absolute Difference K C++
JAVA
Time - O(n + m)
Space - O(m)
Easy
2011 Final Value of Variable After Performing Operations C++
JAVA
Time - O(n)
Space - O(m)
Easy
2023 Number of Pairs of Strings With Concatenation Equal to Target JAVA Time - O(n * m)
Space - O(n)
Easy
2078 Two Furthest Houses With Different Colors C++
JAVA
Time - O(n)
Space - O(1)
Easy
2079 Watering Plants C++
JAVA
Time - O(n)
Space - O(1)
Medium
2114 Maximum Number of Words Found in Sentences C++
JAVA
Time - O(n * m)
Space - O(1)
Easy
2125 Number of Laser Beams in a Bank C++
JAVA
Time - O(n * m)
Space - O(1)
Medium
2161 Partition Array According to Given Pivot JAVA Time - O(n)
Space - O(1)
Medium

String

# Title Solution Complexity Difficulty
5 Longest Palindromic Substring JAVA Time - O(n2)
Space - O(1)
Medium
49 Group Anagrams JAVA Time - O(n * m)
Space - O(n)
Medium
67 Add Binary JAVA Time - O(max(n, m))
Space - O(max(n, m))
Easy
125 Valid Palindrome C++
JAVA
Time - O(n)
Space - O(1)
Easy
151 Reverse Words in a String JAVA Time - O(n * m)
Space - O(n)
Medium
165 Compare Version Numbers C++
JAVA
Time - O(max(n, m))
Space - O(1)
Medium
171 Excel Sheet Column Number C++
JAVA
Time - O(n)
Space - O(1)
Easy
205 Isomorphic Strings C++
JAVA
Time - O(n)
Space - O(1)
Easy
242 Valid Anagram JAVA Time - O(n)
Space - O(1)
Easy
290 Word Pattern JAVA Time - O(n * m)
Space - O(n)
Easy
344 Reverse String C++
JAVA
Time - O(n)
Space - O(1)
Easy
389 Find the Difference C++
JAVA
Time - O(n)
Space - O(1)
Easy
392 Is Subsequence C++
JAVA
Time - O(n)
Space - O(1)
Easy
409 Longest Palindrome JAVA Time - O(n)
Space - O(n)
Easy
438 Find All Anagrams in a String JAVA Time - O(n)
Space - O(n)
Medium
500 Keyboard Row JAVA Time - O(n)
Space - O(n)
Easy
520 Detect Capital C++
JAVA
Time - O(n)
Space - O(1)
Easy
567 Permutation in String C++
JAVA
Time - O(n)
Space - O(1)
Medium
647 Palindromic Substrings C++
JAVA
Time - O(n2)
Space - O(1)
Medium
680 Valid Palindrome II C++
JAVA
Time - O(n)
Space - O(1)
Easy
796 Rotate String C++
JAVA
Time - O(m * n)
Space - O(1)
Easy
848 Shifting Letters C++
JAVA
Time - O(n)
Space - O(1)
Medium
1446 Consecutive Characters C++
JAVA
Time - O(n)
Space - O(1)
Easy
1461 Check If a String Contains All Binary Codes of Size K JAVA Time - O(n)
Space - O(2k)
Medium
1528 Shuffle String C++
JAVA
Time - O(n)
Space - O(1)
Easy
1544 Make The String Great C++
JAVA
Time - O(n)
Space - O(1)
Easy
1662 Check If Two String Arrays are Equivalent C++
JAVA
Time - O(n)
Space - O(1)
Easy
1678 Goal Parser Interpretation C++
JAVA
Time - O(n)
Space - O(1)
Easy
1689 Partitioning Into Minimum Number Of Deci-Binary Numbers JAVA Time - O(n)
Space - O(1)
Medium
1790 Check if One String Swap Can Make Strings Equal C++
JAVA
Time - O(n)
Space - O(1)
Easy
1769 Minimum Number of Operations to Move All Balls to Each Box C++
JAVA
Time - O(n)
Space - O(n)
Medium
1796 Second Largest Digit in a String C++
JAVA
Time - O(n)
Space - O(1)
Easy
1816 Truncate Sentence C++
JAVA
Time - O(n)
Space - O(1)
Easy
1844 Replace All Digits with Characters C++
JAVA
Time - O(n)
Space - O(1)
Easy
1903 Largest Odd Number in String C++
JAVA
Time - O(n)
Space - O(1)
Easy
1910 Remove All Occurrences of a Substring C++
JAVA
Time - O(m * n)
Space - O(n)
Medium
1945 Sum of Digits of String After Convert C++
JAVA
Time - O(n)
Space - O(1)
Easy
1941 Check if All Characters Have Equal Number of Occurrences C++
JAVA
Time - O(n)
Space - O(1)
Easy
2000 Reverse Prefix of Word C++
JAVA
Time - O(n)
Space - O(1)
Easy
2042 Check if Numbers Are Ascending in a Sentence C++
JAVA
Time - O(n)
Space - O(1)
Easy
2103 Rings and Rods C++
JAVA
Time - O(n)
Space - O(1)
Easy
1456 Maximum Number of Vowels in a Substring of Given Length C++
JAVA
Time - O(n)
Space - O(1)
Medium
2068 Check Whether Two Strings are Almost Equivalent C++
JAVA
Time - O(n)
Space - O(1)
Easy
2124 Check if All A's Appears Before All B's C++
JAVA
Time - O(n)
Space - O(1)
Easy
2129 Capitalize the Title Explanation
C++
JAVA
Time - O(n)
Space - O(1)
Easy

Matrix

# Title Solution Complexity Difficulty Tags
73 Set Matrix Zeroes JAVA Time - O(m * n)
Space - O(m * n)
Easy Array, HashTable
566 Reshape the Matrix C++
JAVA
Time - O(m * n)
Space - O(1)
Easy Array, Simulation
867 Transpose Matrix C++
JAVA
Time - O(m * n)
Space - O(1)
Easy Array, Simulation
1260 Shift 2D Grid JAVA Time - O(n)
Space - O(1)
Easy Array, Simulation
1572 Matrix Diagonal Sum C++
JAVA
Time - O(n)
Space - O(1)
Easy Array
1582 Special Positions in a Binary Matrix C++
JAVA
Time - O(m * n)
Space - O(1)
Easy Array

Hash Table

# Title Solution Complexity Difficulty Tags
1 Two Sum JAVA Time - O(n)
Space - O(n)
Easy Array
49 Group Anagrams JAVA Time - O(n * m)
Space - O(n)
Medium String, Sorting
500 Keyboard Row JAVA Time - O(n)
Space - O(n)
Easy Array, String
1207 Unique Number of Occurrences JAVA Time - O(n)
Space - O(n)
Easy Array
1365 How Many Numbers Are Smaller Than the Current Number C++
JAVA
Time - O(n + m)
Space - O(m)
Easy Array, Sorting, Counting
2053 Kth Distinct String in an Array JAVA Time - O(n)
Space - O(n)
Easy Array, String, Counting
2085 Count Common Words With One Occurrence JAVA Time - O(n + m)
Space - O(n)
Easy Array, String, Counting

Binary Search

# Title Solution Complexity Difficulty Tags
33 Search in Rotated Sorted Array C++
JAVA
Time - O(log2(n))
Space - O(1)
Medium Array
74 Search a 2D Matrix C++
JAVA
Time - O(log2(m * n))
Space - O(1)
Medium Array, Matrix
153 Find Minimum in Rotated Sorted Array C++
JAVA
Time - O(log2(n))
Space - O(1)
Medium Array
162 Find Peak Element C++
JAVA
Time - O(log2(n))
Space - O(1)
Medium Array
704 Binary Search C++
JAVA
Time - O(log2(n))
Space - O(1)
Easy Array

Sorting

# Title Solution Complexity Difficulty
1365 How Many Numbers Are Smaller Than the Current Number C++
JAVA
Time - O(n + m)
Space - O(m)
Easy

Two Pointers

# Title Solution Complexity Difficulty
80 Remove Duplicates from Sorted Array II C++
JAVA
Time - O(n)
Space - O(1)
Medium

Dynamic Programming

# Title Solution Complexity Difficulty Tags
70 Climbing Stairs C++
JAVA
Time - O(n)
Space - O(1)
Easy Math, Memoization
264 Ugly Number II C++
JAVA
Time - O(n)
Space - O(n)
Medium HashTable, Math, Heap(Priority Queue)
338 Counting Bits C++
JAVA
Time - O(n)
Space - O(n)
Easy Bit Manipulation
1137 N-th Tribonacci Number C++
JAVA
Time - O(n)
Space - O(1)
Easy Math, Memoization
1646 Get Maximum in Generated Array C++
JAVA
Time - O(n)
Space - O(n)
Easy Array, Simulation

Releases

No releases published

Packages

No packages published