Leetcode By Shayan

Leetcode Solutions By Shayan

View on GitHub

Glossary

question my answers tags
🟢 1-Two Sum go  
🟡 2-Add Two Numbers python  
🟡 3-Longest Substring Without Repeating Characters python, php  
🟡 6-Zigzag Conversion java (hash map), java (math)  
🟡 11-Container With Most Water go (binary search), go (two pointer)  
🟡 15-3Sum go  
🟡 19-Remove Nth Node From End of List python (two traverse)  
🟢 20-Valid Parentheses javascript  
🟢 21-Merge Two Sorted Lists python, go  
🟡 22-Generate Parentheses go  
🔴 23-Merge k Sorted Lists javascript  
🟡 24-Swap Nodes in Pairs go  
🟢 26-Remove Duplicates from Sorted Array go, java  
🟢 27-Remove Element go, java  
🟢 28-Find the Index of the First Occurrence in a String java  
🟡 33-Search in Rotated Sorted Array python  
🟡 34-Find First and Last Position of Element in Sorted Array php  
🟢 35-Search Insert Position javascript  
🟡 36-Valid Sudoku go (concurrency)  
🟡 45-Jump Game II java  
🟡 48-Rotate Image python  
🟡 49-Group Anagrams python  
🟢 53-Maximum Subarray python  
🟡 55-Jump Game python (BFS), python (DP), java (pointer)  
🟡 59-Spiral Matrix II go  
🟡 63-Unique Paths II php  
🟡 64-Minimum Path Sum python  
🟢 67-Add Binary javascript (bitwise), javascript (numeric)  
🔴 68-Text Justification java  
🟡 71-Simplify Path javascript  
🔴 72-Edit Distance python (top-down DP), python (bottom-up DP)  
🟡 73-Set Matrix Zeroes python  
🟡 80-Remove Duplicates from Sorted Array II go, java  
🔴 84-Largest Rectangle in Histogram go  
🔴 87-Scramble String python  
🟢 88-Merge Sorted Array go, java  
🟡 93-Restore IP Addresses python  
🟢 94-Binary Tree Inorder Traversal python  
🟡 98-Validate Binary Search Tree javascript  
🟢 100-Same Tree python  
🟢 104-Maximum Depth of Binary Tree javascript (DFS), go (recursive)  
🟡 101-Symmetric Tree go  
🟡 102-Binary Tree Level Order Traversal python  
🟡 105-Construct Binary Tree from Preorder and Inorder Traversal go  
🟡 106-Construct Binary Tree from Inorder and Postorder Traversal javascript  
🟢 108-Convert Sorted Array to Binary Search Tree python  
🟡 109-Convert Sorted List to Binary Search Tree javascript  
🟢 112-Path Sum python  
🟢 121-Best Time to Buy and Sell Stock python, go  
🟢 125-Valid Palindrome php  
🟡 122-Best Time to Buy and Sell Stock II python, go  
🟡 128-Longest Consecutive Sequence go  
🟡 129-Sum Root to Leaf Numbers php  
🟡 133-Clone Graph python  
🟡 134-Gas Station python  
🔴 135-Candy java  
🟢 144-Binary Tree Preorder Traversal python  
🟢 145-Binary Tree Postorder Traversal go  
🟡 146-LRU Cache go (heap), go (linked-list) DS
🔴 149-Max Points on a Line python  
🟡 150-Evaluate Reverse Polish Notation go  
🟡 151-Reverse Words in a String go  
🟡 155-Min Stack php (array), go (stack) DS
🟡 167-Two Sum II - Input Array Is Sorted go  
🟢 169-Majority Element go (hashmap), java (streaming algorithm)  
🟡 172-Factorial Trailing Zeroes python  
🟡 184-Department Highest Salary sql  
🟡 189-Rotate Array javascript, java  
🟢 191-Number of 1 Bits go  
🟢 195-Tenth Line bash  
🟡 198-House Robber go  
🟡 199-Binary Tree Right Side View python  
🟡 200-Number of Islands python  
🟢 202-Happy Number php  
🟢 203-Remove Linked List Elements php  
🟢 206-Reverse a Linked List python, go  
🟡 208-Implement Trie (Prefix Tree) python DS
🟡 211-Design Add and Search Words Data Structure go (hashmap), go (trie)  
🟡 215-Kth Largest Element in an Array go  
🟢 217-Contains Duplicate php (hash map)  
🟢 222-Count Complete Tree Nodes python  
🟢 226-Invert Binary Tree python (recursion), python (traverse)  
🟢 228-Summary Ranges go  
🟢 232-Implement Queue using Stacks python  
🟢 235-Lowest Common Ancestor of BST python  
🟡 237-Delete Node in a Linked List python, java  
🟡 238-Product of Array Except Self go  
🟢 242-Valid Anagram python  
🟡 271-Encode and Decode Strings python  
🟡 274-H-Index go  
🟢 278-First Bad Version php  
🟢 283-Move Zeroes go (bubble sort like) , go (2 pointer)  
🟡 328-Odd Even Linked List go  
🟢 345-Reverse Vowels of a String go  
🟡 347-Top K Frequent Elements go  
🟢 349-Intersection of Two Arrays go  
🟢 383-Ransom Note go  
🟢 392-Is Subsequence python  
🟡 399-Evaluate Division go  
🟡 402-Remove K Digits go  
🟡 427-Construct Quad Tree python DS
🟡 443-String Compression go  
🟢 463-Island Perimeter java  
🟢 496-Next Greater Element I go  
🟡 503-Next Greater Element II go  
🟢 506-Relative Ranks java  
🟢 509-Fibonacci Number php  
🟢 530-Minimum Absolute Difference in BST go  
🟡 540-Single Element in a Sorted Array php  
🟡 547-Number of Provinces go  
🟡 554-Brick Wall php  
🟢 595-Big Countries pandas  
🟢 605-Can Place Flowers go  
🟢 606-Construct String from Binary Tree go  
🟡 623-Add One Row to Tree java  
🟢 643-Maximum Average Subarray I go  
🟡 649-Dota2 Senate go  
🟡 662-Maximum Width of Binary Tree java  
🟢 680-Valid Palindrome II python  
🟢 696-Count Binary Substrings php  
🟢 703-Kth Largest Element in a Stream go (sorted array)  
🟢 704-Binary Search go  
🟢 705-Design HashSet go DS
🟢 706-Design HashMap python (array) DS
🟡 714-Best Time to Buy and Sell Stock with Transaction Fee go  
🟢 724-Find Pivot Index go  
🟢 733-Flood Fill python  
🟡 735-Asteroid Collision go  
🟡 739-Daily Temperatures go  
🟢 744-Find Smallest Letter Greater Than Target go  
🟢 746-Min Cost Climbing Stairs python  
🟡 785-Is Graph Bipartite? go  
🟡 791-Custom Sort String go  
🟡 792-Number of Matching Subsequences python  
🟢 796-Rotate String go  
🟢 844-Backspace String Compare python  
🟡 853-Car Fleet go  
🟢 867-Transpose Matrix go  
🟢 872-Leaf-Similar Trees go  
🟢 876-Middle of the Linked List go  
🟢 933-Number of Recent Calls go  
🟡 935-Knight Dialer go  
🟡 946-Validate Stack Sequences javascript  
🟡 970-Powerful Integers php  
🟡 983-Minimum Cost For Tickets python (dp), python (cache)  
🟡 988-Smallest String Starting From Leaf java  
🟢 989-Add to Array-Form of Integer javascript  
🟡 994-Rotting Oranges php  
🟢 997-Find the Town Judge php  
🟢 1005-Maximize Sum Of Array After K Negations go  
🟡 1020-Number of Enclaves python  
🟡 1027-Longest Arithmetic Subsequence go  
🟢 1071-Greatest Common Divisor of Strings go  
🟡 1091-Shortest Path in Binary Matrix go  
🟢 1114-Print in Order python  
🟢 1137-N-th Tribonacci Number python  
🟡 1146-Snapshot Array go DS
🟢 1160-Find Words That Can Be Formed by Characters go  
🟡 1161-Maximum Level Sum of a Binary Tree go  
🟢 1207-Unique Number of Occurrences go  
🟢 1232-Check If It Is a Straight Line go  
🟡 1254-Number of Closed Islands python  
🟢 1266-Minimum Time Visiting All Points go  
🟡 1318-Minimum Flips to Make a OR b Equal to c go  
🟡 1319-Number of Operations to Make Network Connected python  
🟡 1325-Delete Leaves With a Given Value java  
🟡 1339-Maximum Product of Splitted Binary Tree python  
🟢 1351-Count Negative Numbers in a Sorted Matrix php  
🟡 1372-Longest ZigZag Path in a Binary Tree python  
🟡 1376-Time Needed to Inform All Employees go  
🟡 1396-Design Underground System go  
🔴 1402-Reducing Dishes python  
🟢 1422-Maximum Score After Splitting a String go  
🟡 1424-Diagonal Traverse II go  
🟢 1431-Kids With the Greatest Number of Candies go  
🟢 1436-Destination City go  
🟡 1443-Minimum Time to Collect All Apples in a Tree python  
🔴 1444-Number of Ways of Cutting a Pizza python  
🟡 1448-Count Good Nodes in Binary Tree go  
🟡 1456-Maximum Number of Vowels in a Substring of Given Length python  
🟢 1464-Maximum Product of Two Elements in an Array go  
🟡 1466-Reorder Routes to Make All Paths Lead to the City Zero python  
🟢 1475-Final Prices With a Special Discount in a Shop python  
🟢 1480-Running Sum of 1d Array php  
🟢 1491-Average Salary Excluding the Minimum and Maximum Salary go  
🟡 1493-Longest Subarray of 1’s After Deleting One Element go  
🟢 1496-Path Crossing go  
🟢 1502-Can Make Arithmetic Progression From Sequence go  
🟢 1523-Count Odd Numbers in an Interval Range javascript  
🟢 1539-Kth Missing Positive Number javascript  
🟡 1557-Minimum Number of Vertices to Reach All Nodes go  
🟡 1561-Maximum Number of Coins You Can Get go  
🔴 1569-Number of Ways to Reorder Array to Get Same BST go  
🟢 1572-Matrix Diagonal Sum go  
🟢 1603-Design Parking System go  
🟡 1630-Arithmetic Subarrays go  
🟡 1637. Widest Vertical Area Between Two Points Containing No Points go  
🔴 1639-Number of Ways to Form a Target String Given a Dictionary python  
🟡 1657-Determine if Two Strings Are Close go  
🟡 1679-Max Number of K-Sum Pairs go  
🟡 1685-Sum of Absolute Differences in a Sorted Array go  
🟢 1688-Count of Matches in Tournament go  
🟡 1721-Swapping Nodes in a Linked List go  
🟢 1732-Find the Highest Altitude go  
🔴 1739-Building Boxes python  
🟢 1757-Recyclable and Low Fat Products pandas  
🟢 1768-Merge Strings Alternately go  
🟡 1802-Maximum Value at a Given Index in a Bounded Array go  
🟡 1814-Count Nice Pairs in an Array go  
🟡 1887-Reduction Operations to Make the Array Elements Equal go  
🟢 1903-Largest Odd Number in String go  
🟢 1971-Find if Path Exists in Graph python  
🟡 2058-Find the Minimum and Maximum Number of Nodes Between Critical Points go  
🟡 2090-K Radius Subarray Averages go interview
🟡 2095-Delete the Middle Node of a Linked List go  
🟡 2101-Detonate the Maximum Bombs go (normal), go (concurrency)  
🟡 2130-Maximum Twin Sum of a Linked List go (duplicate linked list), typescript (stack)  
🔴 2147-Number of Ways to Divide a Long Corridor go  
🟡 2181-Merge Nodes in Between Zeros go  
🟢 2215-Find the Difference of Two Arrays go  
🔴 2218-Maximum Value of K Coins From Piles python  
🟢 2264-Largest 3-Same-Digit Number in String go  
🟡 2300-Successful Pairs of Spells and Potions python  
🟡 2316-Count Unreachable Pairs of Nodes in an Undirected Graph python  
🔴 2328-Number of Increasing Paths in a Grid go  
🟢 2331-Evaluate Boolean Binary Tree java  
🟡 2352-Equal Row and Column Pairs go  
🟡 2353-Design a Food Rating System go (heap) DS
🟡 2390-Removing Stars From a String javascript  
🟡 2391-Minimum Amount of Time to Collect Garbage go  
🟡 2405-Optimal Partition of String python  
🟡 2439-Minimize Maximum of Array python  
🔴 2448-Minimum Cost to Make Array Equal go  
🟡 2482-Difference Between Ones and Zeros in Row and Column go  
🟡 2487-Remove Nodes From Linked List java  
🟢 2535-Difference Between Element Sum and Digit Sum of an Array python  
🟡 2536-Increment Submatrices by One python  
🟢 2540-Minimum Common Value go  
🟢 2544-Alternating Digit Sum python  
🟡 2545-Sort the Students by Their Kth Score python  
🟡 2546-Apply Bitwise Operations to Make Strings Equal python  
🟢 2566-Maximum Difference by Remapping a Digit python  
🟡 2567-Minimum Score by Changing Two Elements python  
🟡 2568-Minimum Impossible OR python  
🟢 2582-Pass the Pillow python  
🟡 2583-Kth Largest Sum in a Binary Tree python  
🟢 2605-Form Smallest Number From Two Digit Arrays python  
🟡 2606-Find the Substring With Maximum Cost python  
🟢 2614-Prime In Diagonal python  
🟡 2615-Sum of Distances python  
🟢 2619-Array Prototype Last javascript  
🟢 2620-Counter javascript  
🟢 2621-Sleep javascript  
🟡 2622-Cache With Time Limit javascript  
🟡 2623-Memoize javascript  
🟢 2626-Array Reduce Transformation javascript  
🟢 2629-Function Composition javascript  
🟢 2634-Filter Elements from Array javascript  
🟢 2635-Apply Transform Over Each Element in Array javascript  
🟡 2637-Promise Time Limit javascript  
🔴 2642-Design Graph With Shortest Path Calculator go  
🟢 2651-Calculate Delayed Arrival Time python  
🟢 2652-Sum Multiples python  
🟡 2653-Sliding Subarray Beauty python DS
🟢 2665.Counter II javascript  
🟢 2666-Allow One Function Call javascript  
🟢 2667-Create Hello World Function javascript  
🟢 2696-Minimum String Length After Removing Substrings python  
🟢 2697-Lexicographically Smallest Palindrome python  
🟡 2698-Find the Punishment Number of an Integer python  
🟢 2703-Return Length of Arguments Passed javascript  
🟢 2704-To Be Or Not To Be javascript  
🟢 2715. Timeout Cancellation javascript  
🟢 2716-Minimize String Length python  
🟢 2717-Semi-Ordered Permutation go  
🟡 2718-Sum of Matrix After Queries go  
🟢 2723-Add Two Promises javascript  
🟢 2725-Interval Cancellation javascript  
🟢 2733-Neither Minimum nor Maximum go  
🟡 2734-Lexicographically Smallest String After Substring Operation python  
🟡 2735-Collecting Chocolates python  
🟢 2748-Number of Beautiful Pairs go  
🟡 2749-Minimum Operations to Make the Integer Zero go  
🟡 2750-Ways to Split Array Into Good Subarrays go  
🟢 2765-Longest Alternating Subarray go  
🟢 2769-Find the Maximum Achievable Number go  
🟡 2770-Maximum Number of Jumps to Reach the Last Index go  
🟢 2784-Check if Array is Good go  
🟡 2816-Double a Number Represented as a Linked List java  
🟡 2870-Minimum Number of Operations to Make Array Empty javascript  
🟢 3005-Count Elements With Maximum Frequency go  
🟢 3131-Find the Integer Added to Array I java  
🟢 3136-Valid Word java  
🟡 3137-Minimum Number of Operations to Make Word K-Periodic java  
🟡 3138-Minimum Length of Anagram Concatenation java  
🟢 3146-Permutation Difference between Two Strings java  
🟡 3147-Taking Maximum Energy From the Mystic Dungeon java  
🟡 3148-Maximum Difference Score in a Grid java  
🟢 3151-Special Array I java  
🟡 3152-Special Array II java  
🟡 3153-Sum of Digit Differences of All Pairs java  
🟢 3162-Find the Number of Good Pairs I java  
🟡 3163-String Compression III java  
🟢 3560-Find Minimum Log Transportation Cost go  
🟡 3561-Resulting String After Adjacent Removals go  
🟡 3566-Partition Array into Two Equal Product Subsets go  
🟡 3567-Minimum Absolute Difference in Sliding Submatrix go  
🟡 3577-Count the Number of Computer Unlocking Permutations go  
🟡 3597-Partition String go  
🟡 3598-Longest Common Prefix Between Adjacent Strings After Removals go Â