Saimon398/leetcode-solutions

Repository files navigation

Here you can find solutions in JavaScript, Python and SQL languages for some problems from LeetCode. You also can participate in solving these problems by proposing your solution. Don't hesitate to pull your ideas here and enjoy LeetCode.

NumberQuestionHintJS SolutionPython Solution
1Two SumUse a hash table to keep track of the indices of the numbers you've encountered so far.JS SolutionPython Solution
3Longest Substring Without Repeating CharsWhat if index of the first occurrence might help?JS SolutionPython Solution
7Reverse IntegerJS SolutionPython Solution
9Palindrome NumberUse two pointers to make it work faster. Beware of overflow.JS SolutionPython Solution
20Valid ParenthesesUse a stack of characters. When you encounter a closing bracket, check if the top of the stack was the opening for it. If yes, pop it from the stack. Otherwise, return false.JS SolutionPython Solution
28Find the Index of the First Occurrence in a StringJS SolutionPython Solution
32Longest Valid ParenthesesUse a stack of characters.JS SolutionPython Solution
34Find First and Last Position of Element in Sorted ArrayBinary SearchJS SolutionPython Solution
35Search Insert PositionUse binary searchJS SolutionPython Solution
42Trapping Rain WaterJS SolutionPython Solution
58Length of Last WordFilter out the words and empty strings in the words array. Don't forget about removing spaces.JS SolutionPython Solution
62Unique PathsDynamic programming is one of the effective ways to solve it. Just find recurrent formula.JS SolutionPython Solution
63Unique Paths IIUse dynamic programming since, from each cell, you can move to the right or down.JS SolutionPython Solution
64Minimum Path SumRemember that from the second cell, the value of the current cell is the price of the current cell plus the minimum value of the previous onesJS SolutionPython Solution
66Plus OneTry iterating through each digit backwards. What do you do when the digit is a 9?JS SolutionPython Solution
69SqrtUse binary search to make algorithm work fasterJS SolutionPython Solution
70Climbing StairsTo reach nth step, what could have been your previous steps?JS SolutionPython Solution
75Sort ColorsOverwrite array with the total number of 0's, then 1's and followed by 2's. Any sort might be appropriate solution.JS SolutionPython Solution
88Merge Sorted ArrayYou can easily solve this problem if you simply think about two elements at a time rather than two arrays. We know that each of the individual arrays is sorted. What we don't know is how they will intertwine. Can we take a local decision and arrive at an optimal solution?JS SolutionPython Solution
122Best Time to Buy and Sell Stock IIWhat should we do every time there is a valley followed by a peak in price?JS SolutionPython Solution
125Valid PalindromeUse Two PointersJS SolutionsPython Solution
136Single NumberUse Bit Manipulations (XOR)JS SolutionPython Solution
151Reverse Words in a StringJS SolutionPython Solution
155Min StackJS SolutionPython Solution
169Majority ElementJS SolutionPython Solution
191Number of 1 BitsUse Bit ManipulationsJS SolutionPython Solution
197Rising TemperatureSQL SolutionPandas Solution
202Happy NumberJS SolutionPython Solution
204Count PrimesUse Sieve of Eratosthenes.JS SolutionPython Solution
206Reverse Linked ListJS SolutionPython Solution
217Contains DuplicateJS SolutionPython Solution
231Power Of TwoThink of Bit ManipulationsJS SolutionPython Solution
232Implement Queue using StacksJS SolutionPython Solution
242Valid AnagramJS SolutionPython Solution
263Ugly NumberJS SolutionPython Solution
264Ugly Number IIDynamic ProgrammingJS SolutionPython Solution
268Missing NumberBit Manipulation is One of the OptionsJS SolutionPython Solution
300Longest Increasing SubsequenceCompare two last nums in sequence and subsequence. If both are equal, length of LIS is increased by 1JS SolutionPython Solution
322Coin ChangeThink how to use a knapsack problemJS SolutionPython Solution
326Power of ThreeJS SolutionPython Solution
342Power of FourBit ManipulationsJS SolutionsPython Solution
344Reverse StringThe entire logic for reversing a string is based on using the opposite directional two-pointer approachJS SolutionPython Solution
345Reverse Vowels of a StringJS SolutionPython Solution
367Valid Perfect SquareJS SolutionPython Solution
389Find The DifferenceJS SolutionPython Solution
392Is SubsequenceUse two pointers to iterate through the two strings simultaneously.JS SolutionPython Solution
412Fizz BuzzThe first non-standard value must satisfy both conditions.JS SolutionPython Solution
421Maximum XOR of Two Numbers in an ArrayJS SolutionPython Solution
451Sort Characters By FrequencyJS SolutionPython Solution
461Hamming DistanceBit Manipulation (XOR)JS SolutionPython Solution
504Base 7Gorner's algorithm can help with this problemJS SolutionPython Solution
516Longest Palindromic SubsequenceJS SolutionPython Solution
557Reverse Words in a String IIIJS SolutionPython Solution
550Game Analysis IVSQL SolutionPandas Solution
577Employee BonusSQL SolutionPandas Solution
580Managers With At Least 5 Direct ReportsSQL SolutionPandas Solution
584Find Customer RefereeSQL SolutionPandas Solution
595Big CountriesSQL SolutionPandas Solution
596Classes More Than 5 StudentsSQL SolutionPandas Solution
610Triangle JudgementSQL SolutionPandas Solution
619Biggest Single NumberSQL SolutionPandas Solution
620Not Boring MoviesSQL SolutionPandas Solution
704Binary SearchJS SolutionPython Solution
771Jewels and StonesJS SolutionPython Solution
1045Customers Who Bought All ProductsSQL SolutionPandas Solution
1068Products Sales Analysis ISQL SolutionPandas Solution
1070Products Sales Analysis IIISQL SolutionPandas Solution
1075Project Employees ISQL SolutionPandas Solution
1137N-th Tribonacci NumberUse dynamic programmingJS SolutionPython Solution
1141User Activity for the Past 30 Days ISQL SolutionPandas Solution
1143Longest Common SubsequenceTry dynamic programming. DP[i][j] represents the longest common subsequence of text1[0 ... i] & text2[0 ... j].JS SolutionPython Solution
1148Article Views ISQL SolutionPandas Solution
1174Immediate Food Delivery IISQL SolutionPandas Solution
1193Monthly Transactions ISQL SolutionPandas Solution
1207Unique Number of OccurrencesFind the number of occurrences of each element in the array using a hash map.JS SolutionPython Solution
1211Queries Quality And PercentageSQL SolutionPandas Solution
1251Average Selling PriceSQL SolutionPandas Solution
1280Students And ExaminationsSQL SolutionPandas Solution
1287Element Appearing More Than 25% In Sorted ArrayJS SolutionPython Solution
1378Replace Employee ID With The Unique IdentifierSQL SolutionPandas Solution
1381Design a Stack With Increment OperationJS SolutionPython Solution
1523Count Odd Numbers in an Interval RangeJS SolutionPython Solution
1581Customer Who Visited But Did Not Make Any TransactionsSQL SolutionPandas Solution
1633Percentage Of Users Attended A ContestSQL SolutionPandas Solution
1661Average Time Of Process Per MachineSQL SolutionPandas Solution
1683Invalid TweetsSQL SolutionPandas Solution
1729Find Followers CountSQL SolutionPandas Solution
1731The Number Of Employee Which Report To Each EmployeeSQL SolutionPandas Solution
1757Recycle And Low Fat ProductsSQL SolutionPandas Solution
1934Confirmation RateSQL SolutionPandas Solution
1934Confirmation RateSQL SolutionPandas Solution
2356Number of Unique Subjects Taught by Each TeacherSQL SolutionPandas Solution
2455Average Value of Even Numbers That Are Divisible by ThreeJS SolutionPython Solution

About

A tiny collection of all my leetcode solutions in JS, Python and SQL

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published