Skip to content

shumarb/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode

Overview

This repository contains my LeetCode submissions, with entries sorted by:

(Note: Rank indicates the percentage of submissions that my code outperforms in terms of runtime.)

The entries are grouped in the following:

Category Content
Challenges Blind 75, Grind 75, Grind 169, SQL 45
Courses AlgoMonster, Grokking Data Structures & Algorithms for Coding Interviews
Topics Array, Binary Search, Binary Search Tree, Binary Tree, Bit Manipulation, Breadth First Search, Bucket Sort, Counting, Counting Sort, Data Stream, Depth First Search, Design, Divide and Conquer, Dynamic Programming, Enumeration, Geometry, Graph, Greedy, Hash Table, Heap (Priority Queue), Linked List, Math, Matrix, Monotonic Stack, Number Theory, Quick Select, Recursion, Simulation, Sliding Window, Sorting, Stack, String, String Matching, Tree, Trie, Two Pointers, Union Find

Umar's LeetCode Statistics

Easy

Question Submission Runtime Rank
A Number After a Double Reversal Java 0ms 100%
Add Binary Java 2ms 99.94%
Add Digits Java 0ms 100%
Add Strings Java 2ms 61.51%
Add Two Integers Java 0ms 100%
Add to Array-Form of Integer Java 2ms 99.20%
Alternating Digit Sum Java 0ms 100%
Apply Operations to an Array Java 1ms 95.99%
Array Partition Java 48ms 5.12%
Article Views I SQL 619ms 51.14%
Average Salary Excluding the Minimum and Maximum Salary Java 0ms 100%
Average Value of Even Numbers That Are Divisible by Three Java 0ms 100%
Backspace String Compare Java 1ms 78.15%
Balanced Binary Tree Java 0ms 100%
Base 7 Java 1ms 70.47%
Best Time To Buy And Sell Stock Java 2ms 72.40%
Big Countries SQL 461ms 66.33%
Biggest Single Number SQL 406ms 82.18%
Binary Number with Alternating Bits Java 1ms 11.33%
Binary Search Java 0ms 100%
Binary Tree Inorder Traversal Java 0ms 100%
Binary Tree Preorder Traversal Java 0ms 100%
Binary Tree Postorder Traversal Java 0ms 100%
Buy Two Chocolates Java 1ms 100%
Capitalize the Title Java 3ms 88.41%
Check Balanced String Java 1ms 99.21%
Check If N And Its Double Exist Java 2ms 94.12%
Check If Two String Arrays are Equivalent Java 1ms 59.87%
Check If a Word Occurs As a Prefix of Any Word in a Sentence Java 0ms 100%
Check Items Matching a Rule Java 3ms 98.89%
Check if All A's Appears Before All B's Java 0ms 100%
Check if All Characters Have Equal Number of Occurrences Java 1ms 100%
Check if Array is Good Java 2ms 74.84%
Check if Every Row and Column Contains All Numbers Java 4ms 92.01%
Check if Grid Satisfies Conditions Java 4ms 92.01%
Check if Matrix Is X-Matrix Java 0ms 100%
Check if Number Has Equal Digit Count and Digit Value Java 0ms 100%
Check if Numbers Are Ascending in a Sentence Java 0ms 100%
Check if The Number is Fascinating Java 0ms 100%
Check if a String Is an Acronym of Words Java 1ms 100%
Classes More Than 5 Students SQL 471ms 96.18%
Combine Two Tables SQL 629ms 96.12%
Concatenation of Array Java 1ms 96.28%
Consecutive Characters Java 1ms 99.83%
Contains Duplicate Java 7ms 99.29%
Contains Duplicate II Java 18ms 82.31%
Convert Binary Number in a Linked List to Integer Java 0ms 100%
Convert Date to Binary Java 4ms 66.45%
Convert the Temperature Java 0ms 100%
Count Common Words With One Occurrence Java 6ms 89.98%
Count Elements With Maximum Frequency Java 1ms 99.75%
Count Equal and Divisible Pairs in an Array Java 3ms 99.52%
Count Integers With Even Digit Sum Java 1ms 86.87%
Count Largest Group Java 3ms 96.75%
Count Negative Numbers in a Sorted Matrix Java 0ms 100%
Count Number of Pairs With Absolute Difference K Java 4ms 95.49%
Count Pairs Of Similar Strings Java 58ms 41.34%
Count Symmetric Integers Java 44ms 25.05%
Count the Digits That Divide a Number Java 0ms 100%
Count the Number of Consistent Strings Java 6ms 86.92%
Count the Number of Special Characters I Java 1ms 100%
Counting Bits Java 2ms 95%
Counting Words With a Given Prefix Occurrence Java 0ms 100%
Customers Placing The Largest Number Of Orders SQL 799ms 87.57%
Customers Who Never Order SQL 908ms 93.29%
Design HashMap Java 32ms 39.02%
Design HashSet Java 12ms 97.83%
Design an Ordered Stream Java 76ms 99.56%
Destination City Java 2ms 100%
Detect Capital Java 0ms 100%
Difference Between Element Sum and Digit Sum of an Array Java 2ms 98.35%
Distribute Candies Java 31ms 55.24%
Duplicate Emails SQL 865ms 11.83%
Employee Bonus SQL 1659ms 64.38%
Employees Earning More Than Their Managers SQL 1429ms 10.98%
Faulty Keyboard Java 3ms 98.26%
Fibonacci Number Java 0ms 100%
Final Prices With a Special Discount in a Shop Java 2ms 65.61%
Final Value of Variable After Performing Operations Java 1ms 74.56%
Find All Numbers Disappeared in an Array Java 3ms 99.85%
Find Center of Star Graph Java 3ms 34.14%
Find Closest Number to Zero Java 2ms 85.90%
Find Common Elements Between Two Arrays Java 1ms 100%
Find First Palindromic String in the Array Java 1ms 100%
Find Greatest Common Divisor of Array Java 0ms 100%
Find Indices of Stable Mountains Java 1ms 100%
Find Lucky Integer in an Array Java 1ms 100%
Find Mode in Binary Search Tree Java 6ms 44.33%
Find Numbers with Even Number of Digits Java 1ms 98.93%
Find Pivot Index Java 1ms 94.56%
Find Resultant Array After Removing Anagrams Java 5ms 14.27%
Find Smallest Letter Greater Than Target Java 0ms 100%
Find Subsequence of Length K With the Largest Sum Java 8ms 62.37%
Find Target Indices After Sorting Array Java 0ms 100%
Find Valid Pair of Adjacent Digits in String Java 2ms 88.14%
Find Words Containing Character Java 2ms 54.27%
Find Words That Can Be Formed by Characters Java 5ms 87.08%
Find if Digit Game Can Be Won Java 0ms 100%
Find if Path Exists in Graph Java 53ms 88.29%
Find the Difference Java 2ms 62.27%
Find the Difference of Two Arrays Java 11ms 45.10%
Find the Distinct Difference Array Java 5ms 93.20%
Find the Highest Altitude Java 0ms 100%
Find the Index of the First Occurrence in a String Java 0ms 100%
Find the Middle Index in Array Java 0ms 100%
Find the Number of Good Pairs I Java 1ms 100%
Find the Peaks Java 1ms 100%
Find the Town Judge Java 2ms 100%
First Bad Version Java 24ms 98.13%
First Letter to Appear Twice Java 0ms 100%
First Unique Character in a String Java 5ms 93.93%
FizzBuzz Java 1ms 99.52%
Generate a String With Characters That Have Odd Counts Java 1ms 83.40%
Greatest English Letter in Upper and Lower Case Java 4ms 72.30%
Guess Number Higher or Lower Java 0ms 100%
Happy Number Java 0ms 100%
Harshad Number Java 0ms 100%
Height Checker Java 2ms 88.86%
How Many Numbers Are Smaller Than the Current Number Java 5ms 83.20%
Implement Queue Using Stacks Java 0ms 100%
Implement Stack Using Queues Java 0ms 100%
Increasing Order Search Tree Java 0ms 100%
Intersection of Multiple Arrays Java 2ms 100%
Intersection of Two Arrays Java 1ms 98.70%
Intersection of Two Arrays II Java 1ms 98.45%
Invert Binary Tree Java 0ms 100%
Is Subsequence Java 1ms 93.37%
Isomorphic Strings Java 13ms 52.01%
Jewels and Stones Java 1ms 60.50%
K Items With the Maximum Sum Java 1ms 89.54%
Keep Multiplying Found Values by Two Java 0ms 100%
Keyboard Row Java 0ms 100%
Kids With the Greatest Number of Candies Java 1ms 87.73%
Kth Distinct String in an Array Java 6ms 86.06%
Kth Largest Element in a Stream Java 21ms 54.99%
Kth Missing Positive Number Java 2ms 11.57%
Largest Number At Least Twice of Others Java 0ms 100%
Largest Odd Number in String Java 1ms 99.64%
Largest Positive Integer That Exists With Its Negative Java 6ms 61.28%
Largest Triangle Area Java 4ms 99.15%
Last Stone Weight Java 1ms 97.76%
Left and Right Sum Differences Java 2ms 98.18%
Length of Last Word Java 1ms 33.68%
Linked List Cycle Java 0ms 100%
Longest Common Prefix Java 1ms 64.40%
Longest Palindrome Java 7ms 52.78%
Majority Element Java 2ms 99.80%
Make Array Zero by Subtracting Equal Amounts Java 0ms 100%
Make The String Great Java 3ms 62.40%
Matrix Diagonal Sum Java 0ms 100%
Max Consecutive Ones Java 2ms 93.86%
Max Pair Sum in an Array Java 3ms 93.95%
Maximum Count of Positive Integer and Negative Integer Java 0ms 100%
Maximum Depth of Binary Tree Java 0ms 100%
Maximum Difference Between Even and Odd Frequency I Java 1ms 100%
Maximum Number of Balloons Java 3ms 75.90%
Maximum Product Difference Between Two Pairs Java 2ms 98.79%
Maximum Product of Three Numbers Java 11ms 84.46%
Maximum Product of Two Elements in an Array Java 0ms 100%
Maximum Sum With Exactly K Elements Java 1ms 100%
Maximum Units on a Truck Java 8ms 95.90%
Mean of Array After Removing Some Elements Java 11ms 5.94%
Merge Sorted Array Java 1ms 29.79%
Merge Two Binary Trees Java 0ms 100%
Merge Two Sorted Lists Java 0ms 100%
Middle of the Linked List Java 0ms 100%
Minimize String Length Java 3ms 100%
Minimum Absolute Difference in BST Java 0ms 100%
Minimum Average of Smallest and Largest Elements Java 2ms 97.31%
Minimum Common Value Java 2ms 86.22%
Minimum Distance Between BST Nodes Java 0ms 100%
Minimum Element After Replacement With Digit Sum Java 1ms 100%
Minimum Operations to Exceed Threshold Value I Java 0ms 100%
Minimum Sum of Mountain Triplets I Java 1ms 100%
Missing Number Java 0ms 100%
Monotonic Stack Java 1ms 98.82%
Most Common Word Java 17ms 43.61%
Most Frequent Even Element Java 12ms 93.70%
Most Frequent Number Following Key In an Array Java 1ms 100%
Move Zeroes Java 1ms 99.85%
Neither Minimum nor Maximum Java 4ms 99.50%
Next Greater Element I Java 3ms 92.50%
Not Boring Movies SQL 495ms 47.80%
Number of 1 Bits Java 0ms 100%
Number of Common Factors Java 1ms 44.28%
Number of Different Integers in a String Java 3ms 78.75%
Number of Distinct Averages Java 1ms 99.35%
Number of Employees Who Met the Target Java 0ms 100%
Number of Good Pairs Java 0ms 100%
Number of Senior Citizens Java 0ms 100%
Palindrome Linked List Java 4ms 83.80%
Palindrome Number Java 6ms 30.91%
Path Sum Java 0ms 100%
Percentage of Letter in String Java 0ms 100%
Perfect Number Java 2ms 83.64%
Permutation Difference between Two Strings Java 1ms 100%
Plus One Java 0ms 100%
Power of Four Java 0ms 100%
Power of Three Java 7ms 100%
Power of Two Java 0ms 100%
Prime Number of Set Bits in Binary Representation Java 66ms 10.43%
Product Sales Analysis I SQL 1896ms 83.84%
Project Employees I SQL 1032ms 62.20%
Range Sum Query - Immutable Java 8ms 65.10%
Range Sum of BST Java 1ms 45.33%
Rank Transform of an Array Java 25ms 86.01%
Ransom Note Java 1ms 99.14%
Relative Ranks Java 9ms 61.66%
Remove All Adjacent Duplicates In String Java 36ms 48.71%
Remove Duplicates from Sorted Array Java 1ms 64.98%
Remove Duplicates from Sorted List Java 0ms 100%
Remove Element Java 0ms 100%
Remove Linked List Elements Java 1ms 94%
Remove Trailing Zeros From a String Java 1ms 100%
Reverse Linked List Java 0ms 100%
Reverse String Java 0ms 100%
Reverse Vowels of a String Java 4ms 50.91%
Richest Customer Wealth Java 0ms 100%
Row With Maximum Ones Java 5ms 27.61%
Running Sum of 1d Array Java 0ms 100%
Same Tree Java 0ms 100%
Score of a String Java 1ms 99.49%
Search Insert Position Java 0ms 100%
Search in a Binary Search Tree Java 0ms 100%
Second Largest Digit in a String Java 1ms 95.03%
Second Minimum Node In a Binary Tree Java 0ms 100%
Self Dividing Numbers Java 1ms 100%
Separate the Digits in an Array Java 5ms 74.92%
Set Mismatch Java 2ms 95.73%
Sign of the Product of an Array Java 0ms 100%
Smallest Divisible Digit Product I Java 1ms 65.70%
Smallest Even Multiple Java 0ms 100%
Smallest Missing Integer Greater Than Sequential Prefix Sum Java 1ms 92.66%
Sort Array by Increasing Frequency Java 5ms 92.79%
Sort Integers by The Number of 1 Bits Java 7ms 74.98%
Sort the People Java 5ms 97.38%
Sorting the Sentence Java 0ms 100%
Sqrt(x) Java 1ms 87.09%
Squares of a Sorted Array Java 1ms 100%
Subtract the Product and Sum of Digits of an Integer Java 0ms 100%
Sum Multiples Java 3ms 63.36%
Sum of Digits in Base K Java 0ms 100%
Sum of Digits of String After Convert Java 2ms 50.64%
Sum of Squares of Special Elements Java 1ms 100%
Sum of Unique Elements Java 0ms 100%
Take Gifts From the Richest Pile Java 6ms 52.37%
Third Maximum Number Java 1ms 97.13%
Three Consecutive Odds Java 0ms 100%
Three Divisors Java 1ms 61.86%
To Lower Case Java 0ms 100%
Two Sum Java 1ms 98.89%
Two Sum IV - Input is a BST Java 1ms 96.19%
Ugly Number Java 0ms 100%
Uncommon Words from Two Sentences Java 3ms 50.44%
Unique Number of Occurrences Java 2ms 97.94%
Valid Anagram Java 2ms 97.84%
Valid Mountain Array Java 2ms 71.67%
Valid Palindrome Java 2ms 99.08%
Valid Palindrome II Java 4ms 99.71%
Valid Parentheses Java 2ms 97.66%
Valid Perfect Square Java 0ms 100%
Valid Word Java 1ms 99.05%
Word Pattern Java 1ms 82.52%
XOR Operation in an Array Java 0ms 100%
Zigzag Grid Traversal With Skip Java 1ms 100%

Medium

Question Submission Runtime Rank
Add Two Numbers Java 1ms 100%
Check if Number is a Sum of Powers of Three Java 0ms 100%
Container With Most Water Java 5ms 74.40%
Count Primes Java 94ms 82.87%
Count the Number of Special Characters II Java 35ms 49.81%
Daily Temperatures Java 77ms 31.05%
Divide Two Integers Java 4ms 5.52%
Find All Anagrams in a String Java 9ms 91.31%
Find First and Last Position of Element in Sorted Array Java 0ms 100%
Find Good Days to Rob the Bank Java 5ms 88.83%
Find Minimum in Rotated Sorted Array Java 0ms 100%
Find Peak Element Java 0ms 100%
Find the Duplicate Number Java 4ms 88.06%
Find the Kth Largest Integer in the Array Java 79ms 50.60%
Finding Pairs With a Certain Sum Java 153ms 42.39%
Group Anagrams Java 9ms 35.78%
Implement Trie (Prefix Tree) Java 33ms 85.89%
Insert Delete GetRandom O(1) Java 25ms 93.59%
Kth Largest Element in an Array Java 39ms 73.11%
Kth Smallest Element In A Sorted Matrix Java 15ms 55.37%
Kth Smallest Element in a BST Java 0ms 100%
Longest Substring Without Repeated Characters Java 6ms 70.55%
Majority Element II Java 10ms 45.32%
Maximal Score After Applying K Operations Java 164ms 13.81%
Maximum Sum of Distinct Subarrays With Length K Java 54ms 30.96%
Min Stack Java 4ms 97.18%
Minimum Number of Vertices to Reach All Nodes Java 8ms 99.23%
Minimum Operations to Exceed Threshold Value II Java 146ms 71.53%
Minimum Operations to Half Array Sum Java 198ms 74.18%
Minimum Sum of Mountain Triplets II Java 2ms 100%
Next Greater Element II Java 9ms 94.03%
Number of Provinces Java 1ms 88.40%
Peak Index in a Mountain Array Java 0ms 100%
Product of Array Except Self Java 2ms 89.32%
Remove Duplicates from Sorted List II Java 3ms 9.87%
Remove Stones to Minimize the Total Java 600ms 20.43%
Removing Stars From a String Java 87ms 32.57%
Reverse Integer Java 0ms 100%
Search in Rotated Sorted Array Java 0ms 100%
Search in Rotated Sorted Array II Java 0ms 100%
Second Highest Salary SQL 480ms 64.38%
Set Matrix Zeroes Java 1ms 73.86%
Simplify Path Java 5ms 51.87%
Smallest Number in Infinite Set Java 16ms 33.15%
Sort Characters By Frequency Java 14ms 64.64%
Sort Colors Java 0ms 100%
Sort List Java 42ms 5%
Sort an Array Java 41ms 26.79%
Spiral Matrix Java 0ms 100%
Sum of Square Numbers Java 3ms 93.35%
Sum of Two Integers Java 0ms 100%
Swap Nodes in Pairs Java 0ms 100%
Top K Frequent Elements Java 14ms 58.56%
Top K Frequent Words Java 6ms 98%
Two Input Sum II - Input Array Is Sorted Java 2ms 93.40%
Ugly Number II Java 2ms 98.25%
Validate Binary Search Tree Java 2ms 98.25%

Hard

Question Submission Runtime Rank
Find Median from Data Stream Java 92ms 78.28%
Find in Mountain Array Java 0ms 100%
First Missing Positive Java 1ms 100%
Merge k Sorted Lists Java 5ms 35.39%
Number of Visible People in a Queue Java 63ms 34.82%