Skip to content

yandevv/TypescriptLeetCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo Typescript + LeetCode

A repository intended to register my LeetCode challenges developed with Typescript.

Table of Contents

How to Run a Challenge

Installing Dependencies

Almost every challenge is presented with some test cases and console logs to visualize them. So to execute the code, you can use ts-node, tsx or any Typescript compiler to execute and automatically compile code.

But firstly it's needed a version of Node to be able to install the CLI commands below.

To install and use any of them globally:

Installing tsx:

npm install -g tsx

or...

Installing ts-node:

npm install -g ts-node

Executing Code

To execute any of the code challenges presented in this repository, it's needed to comment all the remaining approach's functions in order to execute the code like below.

With tsx:

tsx ./mediumChallenges/primeSubtractionOperation.ts

With ts-node:

ts-node ./mediumChallenges/primeSubtractionOperation.ts

Easy Problems

Challenge Name Topics File
145. Binary Tree Postorder Traversal Stack, Tree, Depth-First Search, Binary Tree binaryTreePostorderTraversal.ts
1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence Two Pointers, String, String Matching checkIfAWordOccursAsAPrefixOfAnyWordInASentence.ts
1346. Check If N and Its Double Exist Array, Hash Table, Two Pointers, Binary Search, Sorting checkIfNAndItsDoubleExist.ts
2490. Circular Sentence String circularSentence.ts
70. Climbing Stairs Math, Dynamic Programming, Memoization climbingStairs.ts
2022. Convert 1D Array Into 2D Array Array, Matrix, Simulation convert1DArrayInto2DArray.ts
3005. Count Elements With Maximum Frequency Array, Hash Table, Counting countElementMaxFrequency.ts
2185. Counting Words With a Given Prefix Array, String, String Matching countingWordsWithAGivenPrefix.ts
3042. Count Prefix and Suffix Pairs I Array, String, Trie, Rolling Hash, String Matching, Hash Function countPrefixAndSuffixPairsI.ts
1684. Count the Number of Consistent Strings Array, Hash Table, String, Bit Manipulation, Counting countTheNumberOfConsistentStrings.ts
1598. Crawler Log Folder Array, String, Stack crawlerLogFolder.ts
1957. Delete Characters to Make Fancy String String deleteCharactersToMakeFancyString.ts
2331. Evaluate Boolean Binary Tree Tree, Depth-First Search, Binary Tree evaluateBooleanBinaryTree.ts
509. Fibonacci Number Math, Dynamic Programming, Recursion, Memoization fibonacciNumber.ts
1791. Find Center of Star Graph Graph findCenterOfStarGraph.ts
1002. Find Common Characters Array, Hash Table, String findCommonCharacters.ts
2485. Find the Pivot Integer Math, Prefix Sum findThePivotInteger.ts
412. Fizz Buzz Math, String, Manipulation fizzBuzz.ts
1051. Height Checker Array, Sorting, Counting Sort heightChecker.ts
350. Intersection of Two Arrays II Array, Hash Table, Two Pointers, Binary Search, Sorting intersectionOfTwoArraysII.ts
463. Island Perimeter Array, Depth-First Search, Breadth-First Search, Matrix islandPerimeter.ts
2053. Kth Distinct String in an Array Array, Hash Table, String, Counting kthDistinctStringInAnArray.ts
703. Kth Largest Element in a Stream Tree, Design, Binary Search Tree, Heap (Priority Queue), Binary Tree, Data Stream kthLargestElementInAStream.ts
2373. Largest Local Values in a Matrix Array, Matrix largestLocalValuesInAMatrix.ts
2441. Largest Positive Integer That Exists With Its Negative Array, Hash Table, Two Pointers, Sorting largestPositiveIntegerThatExistsWithItsNegative.ts
860. Lemonade Change Array, Greedy lemonadeChange.ts
141. Linked List Cycle Hash Table, Linked List, Two Pointers linkedListCycle.ts
14. Longest Common Prefix String, Trie longestCommonPrefix.ts
409. Longest Palindrome Hash Table, String, Greedy longestPalindrome.ts
1380. Lucky Numbers in a Matrix Array, Matrix luckyNumbersInAMatrix.ts
1460. Make Two Arrays Equal by Reversing Subarrays Array, Hash Table, Sorting makeTwoArraysEqualByReversingSubarrays.ts
1422. Maximum Score After Splitting a String String, Prefix Sum maximumScoreAfterSplittingAString.ts
88. Merge Sorted Array Array, Two Pointers, Sorting mergeSortedArray.ts
876. Middle of the Linked List Linked List, Two Pointers middleOfLinkedList.ts
2037. Minimum Number of Moves to Seat Everyone Array, Greedy, Sorting, Counting Sort minimumNumberOfMovesToSeatEveryone.ts
2696. Minimum String Length After Removing Substrings String, Stack, Simulation minimumStringLengthAfterRemovingSubstrings.ts
590. N-ary Tree Postorder Traversal Stack, Tree, Depth-First Search n-aryTreePostorderTraversal.ts
476. Number Complement Bit Manipulation numberComplement.ts
191. Number of 1 Bits Divide and Conquer, Bit Manipulation numberOf1Bits.ts
2678. Number of Senior Citizens Array, String numberOfSeniorCitizens.ts
2582. Pass the Pillow Math, Simulation passThePillow.ts
326. Power of Three Math, Recursion powerOfThree.ts
303. Range Sum Query - Immutable Array, Design, Prefix Sum rangeSumQueryImmutable.ts
1331. Rank Transform of an Array Array, Hash Table, Sorting rankTransformOfAnArray.ts
506. Relative Ranks Array, Sorting, Heap (Priority Queue) relativeRanks.ts
1122. Relative Sort Array Array, Hash Table, Sorting, Counting Sort relativeSortArray.ts
26. Remove Duplicates from Sorted Array Array, Two Pointers removeDuplicatesFromSortedArray.ts
27. Remove Element Array, Two Pointers removeElement.ts
206. Reverse Linked List Linked List, Recursion reverseLinkedList.ts
2000. Reverse Prefix of Word Two Pointers, String, Stack reversePrefixOfWord.ts
344. Reverse String Two Pointers, String reverseString.ts
796. Rotate String String, String Matching rotateString.ts
3110. Score of a String String scoreOfAString.ts
1636. Sort Array by Increasing Frequency Array, Hash Table, Sorting sortArrayByIncreasingFrequency.ts
2418. Sort the People Array, Hash Table, String, Sorting sortThePeople.ts
1608. Special Array With X Elements Greater Than or Equal X Array, Binary Search, Sorting specialArrayWithXElementsGreaterThanOrEqualX.ts
1408. String Matching in an Array Array, String, String Matching stringMatchingInAnArray.ts
1863. Sum of All Subset XOR Totals Array, Math, Backtracking, Bit Manipulation, Combinatorics, Enumeration sumOfAllSubsetsXORTotals.ts
1945. Sum of Digits of String After Convert String, Simulation sumOfDigitsOfStringAfterConvert.ts
1550. Three Consecutive Odds Array threeConsecutiveOdds.ts
1. Two Sum Array, Hash Table twoSum.ts
884. Uncommon Words from Two Sentences Hash Table, String, Counting uncommonWordsFromTwoSentences.ts
242. Valid Anagram Hash Table, String, Counting https://leetcode.com/problems/valid-anagram/description/
125. Valid Palindrome Two Pointers, String validPalindrome.ts
1518. Water Bottles Math, Simulation waterBottles.ts
3151. Special Array I Array specialArrayI.ts
1752. Check if Array Is Sorted and Rotated Array checkIfArrayIsSortedAndRotated.ts
3105. Longest Strictly Increasing or Strictly Decreasing Subarray Array longestStrictlyIncreasingOrStrictlyDecreasingSubarray.ts
1800. Maximum Ascending Subarray Sum Array maximumAscendingSubarraySum.ts
1790. Check if One String Swap Can Make Strings Equal Hash Table, String, Counting checkIfOneStringSwapCanMakeStringsEqual.ts
3174. Clear Digits String, Stack, Simulation clearDigits.ts
2460. Apply Operations to an Array Array, Two Pointers, Simulation applyOperationsToAnArray.ts
1475. Final Prices With a Special Discount in a Shop Array, Stack, Monotonic Stack finalPricesWithASpecialDiscountInAShop.ts
2570. Merge Two 2D Arrays by Summing Values Array, Hash Table, Two Pointers mergeTwo2DArraysBySummingValues.ts
2558. Take Gifts From the Richest Pile Array. Heap (Priority Queue). Simulation takeGiftsFromTheRichestPile.ts
2965. Find Missing and Repeated Values Array, Hash Table, Math, Matrix findMissingAndRepeatedValues.ts
2379. Minimum Recolors to Get K Consecutive Black Blocks String, Sliding Window minimumRecolorsToGetKConsecutiveBlackBlocks.ts
2529. Maximum Count of Positive Integer and Negative Integer Array, Binary Search, Counting maximumCountOfPositiveIntegerAndNegativeInteger.ts
2206. Divide Array Into Equal Pairs Array, Hash Table, Bit Manipulation, Counting divideArrayIntoEqualPairs.ts
2873. Maximum Value of an Ordered Triplet I Array maximumValueOfAnOrderedTripletI.ts
3396. Minimum Number of Operations to Make Elements in Array Distinct Array, Hash Table minimumNumberOfOperationsToMakeElementsInArrayDistinct.ts
3375. Minimum Operations to Make Array Values Equal to K Array, Hash Table minimumOperationsToMakeArrayValuesEqualToK.ts
2843. Count Symmetric Integers Math, Enumeration countSymmetricIntegers.ts
2176. Count Equal and Divisible Pairs in an Array Array countEqualAndDivisiblePairsInAnArray.ts
1399. Count Largest Group Hash Table, Math countLargestGroup.ts
3392. Count Subarrays of Length Three With a Condition Array countSubarraysOfLengthThreeWithACondition.ts
1295. Find Numbers with Even Number of Digits Array, Math findNumbersWithEvenNumberOfDigits.ts
1128. Number of Equivalent Domino Pairs Array, Hash Table, Counting numberOfEquivalentDominoPairs.ts
1920. Build Array from Permutation Array, Simulation buildArrayFromPermutation.ts
2094. Finding 3-Digit Even Numbers Array, Hash Table, Sorting, Enumeration finding3-DigitEvenNumbers.ts
2900. Longest Unequal Adjacent Groups Subsequence I Array, String, Dynamic Programming, Greedy longestUnequalAdjacentGroupsSubsequenceI.ts
3024. Type of Triangle Array, Math, Sorting typeOfTriangle.ts
2894. Divisible and Non-divisible Sums Difference Math divisibleAndNonDivisibleSumsDifference.ts
2942. Find Words Containing Character Array, String findWordsContainingCharacter.ts
3442. Maximum Difference Between Even and Odd Frequency I Hash Table, String, Counting maximumDifferenceBetweenEvenAndOddFrequencyI.ts
3423. Maximum Difference Between Adjacent Elements in a Circular Array Array maximumDifferenceBetweenAdjacentElementsInACircularArray.ts
2016. Maximum Difference Between Increasing Elements Array maximumDifferenceBetweenIncreasingElements.ts
2566. Maximum Difference by Remapping a Digit Math, Greedy maximumDifferenceByRemappingADigit.ts
2138. Divide a String Into Groups of Size k String, Simulation divideAStringIntoGroupsOfSizeK.ts
2200. Find All K-Distant Indices in an Array Array, Two Pointers findAllKDistantIndicesInAnArray.ts
2099. Find Subsequence of Length K With the Largest Sum Array, Hash Table, Sorting, Heap (Priority Queue)
594. Longest Harmonious Subsequence Array, Hash Table, Sliding Window, Sorting, Counting longestHarmoniousSubsequence.ts

Medium Problems

Challenge Name Topics File
650. 2 Keys Keyboard Math, Dynamic Programming 2KeysKeyboard.ts
2109. Adding Spaces to a String Array, Two Pointers, String, Simulation addingSpacesToAString.ts
623. Add One Row to Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree addOneRowToTree.ts
2486. Append Characters to String to Make Subsequence Two Pointers, String, Greedy appendCharactersToStringToMakeSubsequence.ts
1701. Average Waiting Time Array, Simulation averageWaitingTime.ts
948. Bag of Tokens Array, Two Pointers, Greedy, Sorting bagOfTokens.ts
1382. Balance a Binary Search Tree Divide and Conquer, Greedy, Tree, Depth-First Search, Binary Search Tree, Binary Tree balanceABinarySearchTree.ts
1014. Best Sightseeing Pair Array, Dynamic Programming bestSightseeingPair.ts
1038. Binary Search Tree to Greater Sum Tree Tree, Depth-First Search, Binary Search Tree, Binary Tree binarySearchTreeToGreaterSumTree.ts
2425. Bitwise XOR of All Pairings Array, Bit Manipulation, Brainteaser bitwiseXOROfAllPairings.ts
881. Boats to Save People Array, Two Pointers, Greedy, Sorting boatsToSavePeople.ts
2116. Check if a Parentheses String Can Be Valid String, Stack, Greedy checkIfAParenthesesStringCanBeValid.ts
1497. Check If Array Pairs Are Divisible by k Array, Hash Table, Counting checkIfArrayPairsAreDivisibleByK.ts
40. Combination Sum II Array, Backtracking combinationSumII.ts
165. Compare Version Numbers Two Pointers, String compareVersionNumbers.ts
1400. Construct K Palindrome Strings Hash Table, String, Greedy, Counting constructKPalindromeStrings.ts
523. Continuous Subarray Sum Array, Hash Table, Math, Prefix Sum continuousSubarraySum.ts
2044. Count Number of Maximum Bitwise-OR Subsets Array, Backtracking, Bit Manipulation, Enumeration countNumberOfMaximumBitwise-ORSubsets.ts
1248. Count Number of Nice Subarrays Array, Hash Table, Math, Sliding Window, Prefix Sum countNumberOfNiceSubarrays.ts
1395. Count Number of Teams Array, Dynamic Programming, Binary Indexed Tree, Segment Tree countNumberOfTeams.ts
1267. Count Servers that Communicate Array, Depth-First Search, Breadth-First Search, Union Find, Matrix, Counting countServersThatCommunicate.ts
2563. Count the Number of Fair Pairs Array, Two Pointers, Binary Search, Sorting countTheNumberOfFairPairs.ts
1442. Count Triplets That Can Form Two Arrays of Equal XOR Array, Hash Table, Math, Bit Manipulation, Prefix Sum countTripletsThatCanFormTwoArraysOfEqualXOR.ts
2257. Count Unguarded Cells in the Grid Array, Matrix, Simulation countUnguardedCellsInTheGrid.ts
2559. Count Vowel Strings in Ranges Array, String, Prefix Sum countVowelStringsInRanges.ts
2466. Count Ways To Build Good Strings Dynamic Programming countWaysToBuildGoodStrings.ts
1462. Course Schedule IV Depth-First Search, Breadth-First Search, Graph, Topological Sort courseScheduleIV.ts
2641. Cousins in Binary Tree II Hash Table, Tree, Depth-First Search, Breadth-First Search, Binary Tree cousinsInBinaryTreeII.ts
2196. Create Binary Tree From Descriptions Array, Hash Table, Tree, Binary Tree createBinaryTreeFromDescriptions.ts
791. Custom Sort String Hash Table, String, Sorting customSortString.ts
1325. Delete Leaves With a Given Value Tree, Depth-First Search, Binary Tree deleteLeavesWithAGivenValue.ts
237. Delete Node in a Linked List Linked List deleteNodeInALinkedList.ts
1110. Delete Nodes And Return Forest Array, Hash Table, Tree, Depth-First Search, Binary Tree deleteNodesAndReturnForest.ts
3217. Delete Nodes From Linked List Present in Array Array, Hash Table, Linked List deleteNodesFromLinkedListPresentInArray.ts
1381. Design a Stack With Increment Operation Array, Stack, Design designAStackWithIncrementOperation.ts
241. Different Ways to Add Parentheses Math, String, Dynamic Programming, Recursion, Memoization differentWaysToAddParentheses.ts
979. Distribute Coins in Binary Tree Tree, Depth-First Search, Binary Tree distributeCoinsInBinaryTree.ts
2406. Divide Intervals Into Minimum Number of Groups Array, Two Pointers, Greedy, Sorting, Heap (Priority Queue), Prefix Sum divideIntervalsIntoMinimumNumberOfGroups.ts
2816. Double a Number Represented as a Linked List Linked List, Math, Stack doubleANumberRepresentedAsALinkedList.ts
2707. Extra Characters in a String Array, Hash Table, String, Dynamic Programming, Trie extraCharactersInAString.ts
1992. Find All Groups of Farmland Array, Depth-First Search, Breadth-First Search, Matrix findAllGroupsOfFarmland.ts
442. Find All Duplicates in an Array Array, Hash Table findAllTheDuplicatesInAnArray.ts
2924. Find Champion II Graph findChampionII.ts
3011. Find if Array Can Be Sorted Array, Bit Manipulation, Sorting findIfArrayCanBeSorted.ts
515. Find Largest Value in Each Tree Row Tree, Depth-First Search, Breadth-First Search, Binary Tree findLargestValueInEachTreeRow.ts
2028. Find Missing Observations Array, Math, Simulation findMissingObservations.ts
1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance Dynamic Programming. Graph. Shortest Path findTheCityWithTheSmallestNumberOfNeighborsAtAThresholdDistance.ts
3043. Find the Length of the Longest Common Prefix Array, Hash Table, String, Trie findTheLengthOfTheLongestCommonPrefix.ts
2058. Find the Minimum and Maximum Number of Nodes Between Critical Points Linked List findTheMinimumAndMaximumNumberOfNodesBetweenCriticalPoints.ts
2657. Find the Prefix Common Array of Two Arrays Array, Hash Table, Bit Manipulation findThePrefixCommonArrayOfTwoArrays.ts
2812. Find the Safest Path in a Grid Array, Binary Search, Breadth-First Search, Union Find, Heap (Priority Queue), Matrix findTheSafestPathInAGrid.ts
1894. Find the Student that Will Replace the Chalk Array, Binary Search, Simulation, Prefix Sum findTheStudentThatWillReplaceTheChalk.ts
1823. Find the Winner of the Circular Game Array, Math, Recursion, Queue, Simulation findTheWinnerOfTheCircularGame.ts
1605. Find Valid Matrix Given Row and Column Sums Array, Greedy, Matrix findValidMatrixGivenRowAndColumnSums.ts
2661. First Completely Painted Row or Column Array, Hash Table, Matrix firstCompletelyPaintedRowOrColumn.ts
951. Flip Equivalent Binary Trees Tree, Depth-First Search, Binary Tree flipEquivalentBinaryTrees.ts
1208. Get Equal Substrings Within Budget String, Binary Search, Sliding Window, Prefix Sum getEqualSubstringsWithinBudget.ts
2017. Grid Game Array, Matrix, Prefix Sum gridGame.ts
1052. Grumpy Bookstore Owner Array, Sliding Window grumpyBookstoreOwner.ts
846. Hand of Straights Array, Hash Table, Greedy, Sorting handOfStraights.ts
2807. Insert Greatest Common Divisors in Linked List Linked List, Math, Number Theory insertGreatestCommonDivisorsInLinkedList.ts
2583. Kth Largest Sum in a Binary Tree Tree, Breadth-First Search, Sorting, Binary Tree kthLargestSumInABinaryTree.ts
179. Largest Number Array, String, Greedy, Sorting largestNumber.ts
2958. Length of Longest Subarray With at Most K Frequency Array, Hash Table, Sliding Window lengthOfLongestSubarrayWithAtMostKFrequency.ts
386. Lexicographical Numbers Depth-First Search, Trie lexicographicalNumbers.ts
1367. Linked List in Binary Tree Linked List, Tree, Depth-First Search, Binary Tree linkedListIinBinaryTree.ts
1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit Array, Queue, Sliding Window, Heap (Priority Queue), Ordered Set, Monotonic Queue longestContinuousSubarrayWithAbsoluteDiffLessThanOrEqualToLimit.ts
1405. Longest Happy String String, Greedy, Heap (Priority Queue) longestHappyString.ts
1552. Magnetic Force Between Two Balls Array, Binary Search, Sorting magneticForceBetweenTwoBalls.ts
2825. Make String a Subsequence Using Cyclic Increments Two Pointers, String makeStringASubsequenceUsingCyclicIncrements.ts
1765. Map of Highest Peak Array, Breadth-First Search, Matrix mapOfHighestPeak.ts
769. Max Chunks To Make Sorted Array, Stack, Greedy, Sorting, Monotonic Stack maxChunksToMakeSorted.ts
2530. Maximal Score After Applying K Operations Array, Greedy, Heap (Priority Queue) maximalScoreAfterApplyingKOperations.ts
3075. Maximize Happiness of Selected Children Array, Greedy, Sorting maximizeHappinessOfSelectedChildren.ts
1792. Maximum Average Pass Ratio Array, Greedy, Heap (Priority Queue) maximumAveragePassRatio.ts
624. Maximum Distance in Arrays Array, Greedy maximumDistanceInArrays.ts
2554. Maximum Number of Integers to Choose From a Range I Array, Hash Table, Binary Search, Greedy, Sorting maximumNumberOfIntegersToChooseFromARangeI.ts
1937. Maximum Number of Points with Cost Array, Dynamic Programming, Matrix maximumNumberOfPointsWithCost.ts
670. Maximum Swap Math, Greedy maximumSwap.ts
2285. Maximum Total Importance of Roads Greedy, Graph, Sorting, Heap (Priority Queue) maximumTotalImportanceOfRoads.ts
1829. Maximum XOR for Each Query Array, Bit Manipulation, Prefix Sum maximumXORForEachQuery.ts
1669. Merge In Between Linked Lists Linked List mergeInBetweenLinkedLists.ts
2181. Merge Nodes in Between Zeros Linked List, Simulation mergeNodesInBetweenZeros.ts
2429. Minimize XOR Greedy, Bit Manipulation minimizeXOR.ts
983. Minimum Cost For Tickets Array, Dynamic Programming minimumCostForTickets.ts
1653. Minimum Deletions to Make String Balanced String, Dynamic Programming, Stack minimumDeletionsToMakeStringBalanced.ts
1509. Minimum Difference Between Largest and Smallest Value in Three Moves Array, Greedy, Sorting minimumDifferenceBetweenLargestAndSmallestValueInThreeMoves.ts
945. Minimum Increment to Make Array Unique Array, Greedy, Sorting, Counting minimumIncrementToMakeArrayUnique.ts
1750. Minimum Length of String After Deleting Similar Ends Two Pointers, String minimumLengthOfStringAfterDeletingSimilarEnds.ts
3223. Minimum Length of String After Operations Hash Table, String, Counting minimumLengthOfStringAfterOperations.ts
2914. Minimum Number of Changes to Make Binary String Beautiful String minimumNumberOfChangesToMakeBinaryStringBeautiful.ts
1482. Minimum Number of Days to Make m Bouquets Array, Binary Search minimumNumberOfDaysToMakeMBouquets.ts
1769. Minimum Number of Operations to Move All Balls to Each Box Array, String, Prefix Sum minimumNumberOfOperationsToMoveAllBallsToEachBox.ts
2471. Minimum Number of Operations to Sort a Binary Tree by Level Tree, Breadth-First Search, Binary Tree minimumNumberOfOperationsToSortABinaryTreeByLevel.ts
3016. Minimum Number of Pushes to Type Word II Hash Table, String, Greedy, Sorting, Counting minimumNumberOfPushesToTypeWordII.ts
2134. Minimum Swaps to Group All 1's Together II Array, Sliding Window minimumSwapsToGroupAll1sTogetherII.ts
539. Minimum Time Difference Array, Math, String, Sorting minimumTimeDifference.ts
826. Most Profit Assigning Work Array, Two Pointers, Binary Search, Greedy, Sorting mostProfitAssigningWork.ts
2337. Move Pieces to Obtain a String Two Pointers, String movePiecesToObtainAString.ts
729. My Calendar I Array, Binary Search, Design, Segment Tree, Ordered Set myCalendarI.ts
2683. Neighboring Bitwise XOR Array, Bit Manipulation neighboringBitwiseXOR.ts
1530. Number of Good Leaf Nodes Pairs Tree, Depth-First Search, Binary Tree numberOfGoodLeafNodesPairs.ts
200. Number of Islands Array, Depth-First Search, Breadth-First Search, Union Find, Matrix numberOfIslands.ts
1404. Number of Steps to Reduce a Number in Binary Representation to One String, Bit Manipulation numberOfStepsToReduceANumberInBinaryRepresentationToOne.ts
2270. Number of Ways to Split Array Array, Prefix Sum numberOfWaysToSplitArray.ts
131. Palindrome Partitioning String, Dynamic Programming, Backtracking palindromePartitioning.ts
1219. Path with Maximum Gold Array, Backtracking, Matrix pathWithMaximumGold.ts
567. Permutation in String Hash Table, Two Pointers, String, Sliding Window permutationInString.ts
2601. Prime Subtraction Operation Array, Math, Binary Search, Greedy, Number Theory primeSubtractionOperation.ts
1508. Range Sum of Sorted Subarray Sums Array, Two Pointers, Binary Search, Sorting rangeSumOfSortedSubarraySums.ts
959. Regions Cut By Slashes Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Matrix regionsCutBySlashes.ts
2487. Remove Nodes From Linked List Linked List, Stack, Recursion, Monotonic Stack removeNodesFromLinkedList.ts
648. Replace Words Array, Hash Table, String, Trie replaceWords.ts
2415. Reverse Odd Levels of Binary Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree reverseOddLevelsOfBinaryTree.ts
861. Score After Flipping Matrix Array, Greedy, Bit Manipulation, Matrix scoreAfterFlippingMatrix.ts
1813. Sentence Similarity III Array, Two Pointers, String sentenceSimilarityIII.ts
2938. Separate Black and White Balls Two Pointers, String, Greedy separateBlackAndWhiteBalls.ts
2381. Shifting Letters II Array, String, Prefix Sum shiftingLettersII.ts
3097. Shortest Subarray With OR at Least K II Array, Bit Manipulation, Sliding Window shortestSubarrayWithORAtLeastKII.ts
260. Single Number III Array, Bit Manipulation singleNumberIII.ts
912. Sort an Array Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort sortAnArray.ts
75. Sort Colors Array, Two Pointers, Sorting sortColors.ts
2191. Sort the Jumbled Numbers Array, Sorting sortTheJumbledNumbers.ts
885. Spiral Matrix III Array, Matrix, Simulation spiralMatrixIII.ts
2326. Spiral Matrix IV Array, Linked List, Matrix, Simulation spiralMatrixIV.ts
1593. Split a String Into the Max Number of Unique Substrings Hash Table, String, Backtracking splitAStringIntoTheMaxNumberOfUniqueSubstrings.ts
725. Split Linked List in Parts Linked List splitLinkedListInParts.ts
2096. Step-By-Step Directions From a Binary Tree Node to Another String, Tree, Depth-First Search, Binary Tree StepDirectionsFromABinaryTreeNodeToAnother.ts
3163. String Compression III String stringCompressionIII.ts
713. Subarray Product Less Than K Array, Binary Search, Sliding Window, Prefix Sum subarrayProductLessThanK.ts
974. Subarray Sums Divisible by K Array, Hash Table, Prefix Sum subarraySumsDivisibleByK.ts
78. Subsets Array, Backtracking, Bit Manipulation subsets.ts
633. Sum of Square Numbers Math, Two Pointers, Binary Search sumOfSquareNumbers.ts
129. Sum Root to Leaf Numbers Tree, Depth-First Search, Binary Tree sumRootToLeafNumbers.ts
494. Target Sum Array, Dynamic Programming, Backtracking targetSum.ts
2597. The Number of Beautiful Subsets Array, Hash Table, Math, Dynamic Programming, Backtracking, Sorting, Combinatorics theNumberOfBeautifulSubsets.ts
1942. The Number of the Smallest Unoccupied Chair Array, Hash Table, Heap (Priority Queue) theNumberOfTheSmallestUnoccupiedChair.ts
264. Ugly Number II Hash Table, Math, Dynamic Programming, Heap (Priority Queue) uglyNumberII.ts
1930. Unique Length-3 Palindromic Subsequences Hash Table, String, Bit Manipulation, Prefix Sum uniqueLength-3PalindromicSubsequences.ts
874. Walking Robot Simulation Array, Hash Table, Simulation walkingRobotSimulation.ts
916. Word Subsets Array, Hash Table, String wordSubsets.ts
1310. XOR Queries of a Subarray Array, Bit Manipulation, Prefix Sum xorQueriesOfASubarray.ts
1079. Letter Tile Possibilities Hash Table, String, Backtracking, Counting letterTilePossibilities.ts
1726. Tuple with Same Product Array, Hash Table, Counting tupleWithSameProduct.ts
3160. Find the Number of Distinct Colors Among the Balls Array, Hash Table, Simulation findTheNumberOfDistinctColorsAmongTheBalls.ts
2364. Count Number of Bad Pairs Array, Hash Table, Math, Counting countNumberOfBadPairs.ts
2349. Design a Number Container System Hash Table, Design, Heap (Priority Queue), Ordered Set designANumberContainerSystem.ts
1910. Remove All Occurrences of a Substring String, Stack, Simulation removeAllOccurrencesOfASubstring.ts
2342. Max Sum of a Pair With Equal Sum of Digits Array, Hash Table, Sorting, Heap (Priority Queue) maxSumOfAPairWithEqualSumOfDigits.ts
3066. Minimum Operations to Exceed Threshold Value II Array, Heap (Priority Queue), Simulation minimumOperationsToExceedThresholdValueII.ts
1352. Product of the Last K Numbers Array, Math, Design, Data Stream, Prefix Sum productOfTheLastKNumbers.ts
2698. Find the Punishment Number of an Integer Math, Backtracking findThePunishmentNumberOfAnInteger.ts
1718. Construct the Lexicographically Largest Valid Sequence Array, Backtracking constructTheLexicographicallyLargestValidSequence.ts
2375. Construct Smallest Number From DI String String, Backtracking, Stack, Greedy constructSmallestNumberFromDIString.ts
1415. The k-th Lexicographical String of All Happy Strings of Length n String, Backtracking theKthLexicographicalStringOfAllHappyStringsOfLengthN.ts
1980. Find Unique Binary String Array, Hash Table, String, Backtracking findUniqueBinaryString.ts
1261. Find Elements in a Contaminated Binary Tree Hash Table, Tree, Depth-First Search, Breadth-First Search, Design, Binary Tree findElementsInAContaminatedBinaryTree.ts
1524. Number of Sub-arrays With Odd Sum Array, Math, Dynamic Programming, Prefix Sum numberOfSubarraysWithOddSum.ts
2467. Most Profitable Path in a Tree Array, Tree, Depth-First Search, Breadth-First Search, Graph mostProfitablePathInATree.ts
889. Construct Binary Tree from Preorder and Postorder Traversal Array, Hash Table, Divide and Conquer, Tree, Binary Tree constructBinaryTreeFromPreorderAndPostorderTraversal.ts
873. Length of Longest Fibonacci Subsequence Array, Hash Table, Dynamic Programming lengthOfLongestFibonacciSubsequence.ts
1749. Maximum Absolute Sum of Any Subarray Array, Dynamic Programming maximumAbsoluteSumOfAnySubarray.ts
2593. Find Score of an Array After Marking All Elements Array, Hash Table, Sorting, Heap (Priority Queue), Simulation findScoreOfAnArrayAfterMarkingAllElements.ts
2161. Partition Array According to Given Pivot Array. Two Pointers. Simulation partitionArrayAccordingToGivenPivot.ts
1780. Check if Number is a Sum of Powers of Three Math checkIfNumberIsASumOfPowersOfThree.ts
2579. Count Total Number of Colored Cells Math countTotalNumberOfColoredCells.ts
2523. Closest Prime Numbers in Range Math, Number Theory closestPrimeNumbersInRange.ts
3208. Alternating Groups II Array, Sliding Window alternatingGroupsII.ts
3306. Count of Substrings Containing Every Vowel and K Consonants II Hash Table, String, Sliding Window countOfSubstringsContainingEveryVowelAndKConsonantsII.ts
1358. Number of Substrings Containing All Three Characters Hash Table, String, Sliding Window numberOfSubstringsContainingAllThreeCharacters.ts
3356. Zero Array Transformation II Array, Binary Search, Prefix Sum zeroArrayTransformationII.ts
2226. Maximum Candies Allocated to K Children Array, Binary Search maximumCandiesAllocatedToKChildren.ts
2560. House Robber IV Arra, Binary Search houseRobberIV.ts
2401. Longest Nice Subarray Array, Bit Manipulation, Sliding Window longestNiceSubarray.ts
3191. Minimum Operations to Make Binary Array Elements Equal to One I Array, Bit Manipulation, Queue, Sliding Window, Prefix Sum minimumOperationsToMakeBinaryArrayElementsEqualToOneI.ts
2115. Find All Possible Recipes from Given Supplies Array, Hash Table, String, Graph, Topological Sort findAllPossibleRecipesFromGivenSupplies.ts
3169. Count Days Without Meetings Array, Sorting countDaysWithoutMeetings.ts
3394. Check if Grid can be Cut into Sections Array, Sorting checkIfGridCanBeCutIntoSections.ts
2033. Minimum Operations to Make a Uni-Value Grid Array, Math, Sorting, Matrix minimumOperationsToMakeAUniValueGrid.ts
2780. Minimum Index of a Valid Split Array, Hash Table, Sorting minimumIndexOfAValidSplit.ts
2140. Solving Questions With Brainpower Array, Dynamic Programming solvingQuestionsWithBrainpower.ts
2874. Maximum Value of an Ordered Triplet II Array maximumValueOfAnOrderedTripletII.ts
368. Largest Divisible Subset Array, Math, Dynamic Programming, Sorting largestDivisibleSubset.ts
416. Partition Equal Subset Sum Array, Dynamic Programming partitionEqualSubsetSum.ts
1922. Count Good Numbers Math, Recursion countGoodNumbers.ts
2070. Most Beautiful Item for Each Query Array, Binary Search, Sorting mostBeautifulItemForEachQuery.ts
2537. Count the Number of Good Subarrays Array, Hash Table, Sliding Window countTheNumberOfGoodSubarrays.ts
2145. Count the Hidden Sequences Array, Prefix Sum countTheHiddenSequences.ts
38. Count and Say String countAndSay.ts
781. Rabbits in Forest Array, Hash Table, Math, Greedy rabbitsInForest.ts
2145. Count the Hidden Sequences Array, Prefix Sum countTheHiddenSequences.ts
2799. Count Complete Subarrays in an Array Array, Hash Table, Sliding Window countCompleteSubarraysInAnArray.ts
2845. Count of Interesting Subarrays Array, Hash Table, Prefix Sum countOfInterestingSubarrays.ts
2962. Count Subarrays Where Max Element Appears at Least K Times Array, Sliding Window countSubarraysWhereMaxElementAppearsAtLeastKTimes.ts
1007. Minimum Domino Rotations For Equal Row Array, Greedy minimumDominoRotationsForEqualRow.ts
790. Domino and Tromino Tiling Dynamic Programming
3341. Find Minimum Time to Reach Last Room I Array, Graph, Heap (Priority Queue), Matrix, Shortest Path findMinimumTimeToReachLastRoomI.ts
3342. Find Minimum Time to Reach Last Room II Array, Graph, Heap (Priority Queue), Matrix, Shortest Path findMinimumTimeToReachLastRoomII.ts
3335. Total Characters in String After Transformations I Hash Table, Math, String, Dynamic Programming, Counting totalCharactersInStringAfterTransformationsI.ts
3355. Zero Array Transformation I Array, Prefix Sum zeroArrayTransformationI.ts
73. Set Matrix Zeroes Array, Hash Table, Matrix setMatrixZeroes.ts
2131. Longest Palindrome by Concatenating Two Letter Words Array, Hash Table, String, Greedy, Counting longestPalindromeByConcatenatingTwoLetterWords.ts
3372. Maximize the Number of Target Nodes After Connecting Trees I Tree, Depth-First Search, Breadth-First Search maximizeTheNumberOfTargetNodesAfterConnectingTreesI.ts
3403. Find the Lexicographically Largest String From the Box I Two Pointers, String, Enumeration findTheLexicographicallyLargestStringFromTheBoxI.ts
3403. Find the Lexicographically Largest String From the Box I Two Pointers, String, Enumeration findTheLexicographicallyLargestStringFromTheBoxI.ts
1061. Lexicographically Smallest Equivalent String String, Union Find lexicographicallySmallestEquivalentString.ts
2434. Using a Robot to Print the Lexicographically Smallest String Hash Table, String, Stack, Greedy usingARobotToPrintTheLexicographicallySmallestString.ts
3170. Lexicographically Minimum String After Removing Stars Hash Table, String, Stack, Greedy, Heap (Priority Queue) lexicographicallyMinimumStringAfterRemovingStars.ts
1432. Max Difference You Can Get From Changing an Integer Math, Greedy maxDifferenceYouCanGetFromChangingAnInteger.ts
2966. Divide Array Into Arrays With Max Difference Array, Greedy, Sorting divideArrayIntoArraysWithMaxDifference.ts
2294. Partition Array Such That Maximum Difference Is K Array, Greedy, Sorting partitionArraySuchThatMaximumDifferenceIsK.ts
3085. Minimum Deletions to Make String K-Special Hash Table, String, Greedy, Sorting, Counting minimumDeletionsToMakeStringKSpecial.ts
2311. Longest Binary Subsequence Less Than or Equal to K String, Dynamic Programming, Greedy, Memoization longestBinarySubsequenceLessThanOrEqualToK.ts
1498. Number of Subsequences That Satisfy the Given Sum Condition Array, Two Pointers, Binary Search, Sorting numberOfSubsequencesThatSatisfyTheGivenSumCondition.ts

Hard Problems

Challenge Name Topics File
689. Maximum Sum of 3 Non-Overlapping Subarrays Array, Dynamic Programming maximumSumOf3NonOverlappingSubarrays.ts
1368. Minimum Cost to Make at Least One Valid Path in a Grid Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path minimumCostToMakeAtLeastOneValidPathInAGrid.ts
995. Minimum Number of K Consecutive Bit Flips Array, Bit Manipulation, Queue, Sliding Window, Prefix Sum minimumNumberOfKConsecutivesBitFlips.ts
2290. Minimum Obstacle Removal to Reach Corner Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path minimumObstacleRemovalToReachCorner.ts
2577. Minimum Time to Visit a Cell In a Grid Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path minimumTimeToVisitACellInAGrid.ts
1106. Parsing A Boolean Expression String, Stack, Recursion parsingABooleanExpression.ts
1579. Remove Max Number of Edges to Keep Graph Fully Traversable Union Find, Graph removeMaxNumberOfEdgesToKeepGraphFullyTraversable.ts
214. Shortest Palindrome String, Rolling Hash, String Matching, Hash Function shortestPalindrome.ts
632. Smallest Range Covering Elements from K Lists Array, Hash Table, Greedy, Sliding Window, Sorting, Heap (Priority Queue) smallestRangeCoveringElementsFromKListsSolvedHardTopicsCompanies.ts
2416. Sum of Prefix Scores of Strings Array, String, Trie, Counting sumOfPrefixScoresOfStrings.ts
42. Trapping Rain Water Array, Two Pointers, Dynamic Programming, Stack, Monotonic Stack trappingRainWater.ts
140. Word Break II Array, Hash Table, String, Dynamic Programming, Backtracking, Trie, Memoization wordBreakII.ts
432. All O`one Data Structure Hash Table, Linked List, Design, Doubly-Linked List allO`oneDataStructure.ts
2392. Build a Matrix With Conditions Array, Graph, Topological Sort, Matrix buildAMatrixWithConditions.ts
719. Find K-th Smallest Pair Distance Array, Two Pointers, Binary Search, Sorting findKthSmallestPairDistance.ts
564. Find the Closest Palindrome Math, String findTheClosestPalindrome.ts
3068. Find the Maximum Sum of Node Values Array, Dynamic Programming, Greedy, Bit Manipulation, Tree, Sorting findTheMaximumSumOfNodeValues.ts
273. Integer to English Words Math, String, Recursion integerToEnglishWords.ts
502. IPO Array, Greedy, Sorting, Heap (Priority Queue) IPO.ts
440. K-th Smallest in Lexicographical Order Trie k-thSmallestInLexicographicalOrder.ts
1255. Maximum Score Words Formed by Letters Array, String, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask maximumScoreWordsFormedByLetters.ts
2493. Divide Nodes Into the Maximum Number of Groups Breadth-First Search, Union Find, Graph divideNodesIntoTheMaximumNumberOfGroups.ts
1028. Recover a Tree From Preorder Traversal String, Tree, Depth-First Search, Binary Tree recoverATreeFromPreorderTraversal.ts
1092. Shortest Common Supersequence String, Dynamic Programming shortestCommonSupersequence.ts
3108. Minimum Cost Walk in Weighted Graph Array, Bit Manipulation, Union Find, Graph minimumCostWalkInWeightedGraph.ts
2503. Maximum Number of Points From Grid Queries Array, Two Pointers, Breadth-First Search, Union Find, Sorting, Heap (Priority Queue), Matrix maximumNumberOfPointsFromGridQueries.ts
2551. Put Marbles in Bags Array, Greedy, Sorting, Heap (Priority Queue) putMarblesInBags.ts
2999. Count the Number of Powerful Integers Math, String, Dynamic Programming countTheNumberOfPowerfulIntegers.ts
2179. Count Good Triplets in an Array Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set countGoodTripletsInAnArray.ts
2338. Count the Number of Ideal Arrays Math, Dynamic Programming, Combinatorics, Number Theory countTheNumberOfIdealArrays.ts
2444. Count Subarrays With Fixed Bounds Array, Queue, Sliding Window, Monotonic Queue countSubarraysWithFixedBounds.ts
2302. Count Subarrays With Score Less Than K Array, Binary Search, Sliding Window, Prefix Sum countSubarraysWithScoreLessThanK.ts
3337. Total Characters in String After Transformations II Hash Table, Math, String, Dynamic Programming, Counting totalCharactersInStringAfterTransformationsII.ts
3373. Maximize the Number of Target Nodes After Connecting Trees II Tree, Depth-First Search, Breadth-First Search maximizeTheNumberOfTargetNodesAfterConnectingTreesII.ts
135. Candy Array, Greedy candy.ts
1298. Maximum Candies You Can Get from Boxes Array, Breadth-First Search, Graph maximumCandiesYouCanGetFromBoxes.ts
2040. Kth Smallest Product of Two Sorted Arrays Array, Binary Search kthSmallestProductOfTwoSortedArrays.ts

About

All my Typescript solved challenges of LeetCode.

Topics

Resources

License

Stars

Watchers

Forks