/leetcode

Collection of LeetCode solutions in TypeScript.

Primary LanguageTypeScript

LeetCode Solutions in TypeScript

Ranking Contest Rating Problems Solved Solve Percentage TypeScript

A collection of LeetCode solutions implemented in TypeScript. This repository contains my solutions to various LeetCode problems, organized by problem ID and name.

📁 Project Structure

Each problem is organized in its own directory following the format:

{problem_id}-{problem_name}/
├── README.md                    # Problem description and constraints
├── Solution.md                  # Solution explanation and approach
└── {problem_id}-{problem_name}.ts  # TypeScript solution implementation

🚀 How to Use

  1. Navigate to the problem directory you're interested in
  2. Read the README.md for problem description and constraints
  3. Check the Solution.md for detailed solution explanation, approach, and complexity analysis
  4. Review the {problem_id}-{problem_name}.ts file for the TypeScript implementation

📝 Current Solutions

📋 Arrays
Prefix Sum & Subarray/Product Problems - [0713. Subarray Product Less Than K](./0713-subarray-product-less-than-k/) - [2348. Number Of Zero Filled Subarrays](./2348-number-of-zero-filled-subarrays/) - [3349. Adjacent Increasing Subarrays Detection I](./3349-adjacent-increasing-subarrays-detection-i/) - [3350. Adjacent Increasing Subarrays Detection Ii](./3350-adjacent-increasing-subarrays-detection-ii/) - [3539. Find Sum of Array Product of Magical Sequences](./3539-find-sum-of-array-product-of-magical-sequences/) - [3542. Minimum Operations to Convert All Elements to Zero](./3542-minimum-operations-to-convert-all-elements-to-zero/) - [3587. Minimum Adjacent Swaps To Alternate Parity](./3587-minimum-adjacent-swaps-to-alternate-parity/) - [3599. Partition Array To Minimize Xor](./3599-partition-array-to-minimize-xor/) - [3689. Maximum Total Subarray Value I](./3689-maximum-total-subarray-value-i/) - [3719. Longest Balanced Subarray I](./3719-longest-balanced-subarray-i/)
Sorting, Pairing & Removal - [0014. Longest Common Prefix](./0014-longest-common-prefix/) - [0049. Group Anagrams](./0049-group-anagrams/) - [0073. Set Matrix Zeroes](./0073-set-matrix-zeroes/) - [0075. Sort Colors](./0075-sort-colors/) - [0869. Reordered Power Of 2](./0869-reordered-power-of-2/) - [0976. Largest Perimeter Triangle](./0976-largest-perimeter-triangle/) - [1233. Remove Sub Folders From The Filesystem](./1233-remove-sub-folders-from-the-filesystem/) - [2014. Longest Subsequence Repeated K Times](./2014-longest-subsequence-repeated-k-times/) - [2099. Find Subsequence Of Length K With The Largest Sum](./2099-find-subsequence-of-length-k-with-the-largest-sum/) - [2300. Successful Pairs Of Spells And Potions](./2300-successful-pairs-of-spells-and-potions/) - [2327. Number Of People Aware Of A Secret](./2327-number-of-people-aware-of-a-secret/) - [2402. Meeting Rooms Iii](./2402-meeting-rooms-iii/) - [2406. Divide Intervals Into Minimum Number Of Groups](./2406-divide-intervals-into-minimum-number-of-groups/) - [2410. Maximum Matching Of Players With Trainers](./2410-maximum-matching-of-players-with-trainers/) - [2616. Minimize The Maximum Difference Of Pairs](./2616-minimize-the-maximum-difference-of-pairs/) - [3362. Zero Array Transformation Iii](./3362-zero-array-transformation-iii/) - [3397. Maximum Number Of Distinct Elements After Operations](./3397-maximum-number-of-distinct-elements-after-operations/) - [3424. Minimum Cost To Make Arrays Identical](./3424-minimum-cost-to-make-arrays-identical/) - [3507. Minimum Pair Removal to Sort Array I](./3507-minimum-pair-removal-to-sort-array-i/) - [3510. Minimum Pair Removal to Sort Array II](./3510-minimum-pair-removal-to-sort-array-ii/) - [3536. Maximum Product of Two Digits](./3536-maximum-product-of-two-digits/) - [3538. Merge Operations For Minimum Travel Time](./3538-merge-operations-for-minimum-travel-time/) - [3551. Minimum Swaps To Sort By Digit Sum](./3551-minimum-swaps-to-sort-by-digit-sum/) - [3572. Maximize Ysum By Picking A Triplet Of Distinct Xvalues](./3572-maximize-ysum-by-picking-a-triplet-of-distinct-xvalues/) - [3644. Maximum K To Sort A Permutation](./3644-maximum-k-to-sort-a-permutation/) - [3649. Number Of Perfect Pairs](./3649-number-of-perfect-pairs/) - [3668. Restore Finishing Order](./3668-restore-finishing-order/) - [3727. Maximum Alternating Sum Of Squares](./3727-maximum-alternating-sum-of-squares/)
Counting, Frequency & Miscellaneous
Counting & Frequency
Operations & Transformations
General Array Problems
General Array Problems
Matrix Problems - [0036. Valid Sudoku](./0036-valid-sudoku/) - [0054. Spiral Matrix](./0054-spiral-matrix/) - [0059. Spiral Matrix II](./0059-spiral-matrix-ii/) - [0073. Set Matrix Zeroes](./0073-set-matrix-zeroes/) - [0200. Number Of Islands](./0200-number-of-islands/) - [0407. Trapping Rain Water Ii](./0407-trapping-rain-water-ii/) - [0417. Pacific Atlantic Water Flow](./0417-pacific-atlantic-water-flow/) - [0778. Swim In Rising Water](./0778-swim-in-rising-water/) - [0885. Spiral Matrix III](./0885-spiral-matrix-iii/) - [2326. Spiral Matrix IV](./2326-spiral-matrix-iv/) - [3000. Maximum Area Of Longest Diagonal Rectangle](./3000-maximum-area-of-longest-diagonal-rectangle/) - [3195. Find The Minimum Area To Cover All Ones I](./3195-find-the-minimum-area-to-cover-all-ones-i/) - [3341. Find Minimum Time To Reach Last Room I](./3341-find-minimum-time-to-reach-last-room-i/) - [3342. Find Minimum Time To Reach Last Room Ii](./3342-find-minimum-time-to-reach-last-room-ii/) - [3363. Find The Maximum Number Of Fruits Collected](./3363-find-the-maximum-number-of-fruits-collected/) - [3426. Manhattan Distances Of All Arrangements Of Pieces](./3426-manhattan-distances-of-all-arrangements-of-pieces/) - [3446. Sort Matrix by Diagonals](./3446-sort-matrix-by-diagonals/) - [3459. Length Of Longest V Shaped Diagonal Segment](./3459-length-of-longest-v-shaped-diagonal-segment/) - [3529. Count Cells In Overlapping Horizontal And Vertical Substrings](./3529-count-cells-in-overlapping-horizontal-and-vertical-substrings/) - [3537. Fill A Special Grid](./3537-fill-a-special-grid/) - [3552. Grid Teleportation Traversal](./3552-grid-teleportation-traversal/) - [3567. Minimum Absolute Difference In Sliding Submatrix](./3567-minimum-absolute-difference-in-sliding-submatrix/) - [3603. Minimum Cost Path With Alternating Directions Ii](./3603-minimum-cost-path-with-alternating-directions-ii/) - [3643. Flip Square Submatrix Vertically](./3643-flip-square-submatrix-vertically/)
Two-Pointer & Sliding Window - [0011. Container With Most Water](./0011-container-with-most-water/) - [0013. Roman To Integer](./0013-roman-to-integer/) - [0015. 3Sum](./0015-3sum/) - [0120. Triangle](./0120-triangle/) - [0135. Candy](./0135-candy/) - [0165. Compare Version Numbers](./0165-compare-version-numbers/) - [0326. Power Of Three](./0326-power-of-three/) - [0837. New 21 Game](./0837-new-21-game/) - [0904. Fruit Into Baskets](./0904-fruit-into-baskets/) - [1249. Minimum Remove to Make Valid Parentheses](./1249-minimum-remove-to-make-valid-parentheses/) - [1353. Maximum Number Of Events That Can Be Attended](./1353-maximum-number-of-events-that-can-be-attended/) - [1493. Longest Subarray Of 1s After Deleting One Element](./1493-longest-subarray-of-1s-after-deleting-one-element/) - [1498. Number Of Subsequences That Satisfy The Given Sum Condition](./1498-number-of-subsequences-that-satisfy-the-given-sum-condition/) - [1695. Maximum Erasure Value](./1695-maximum-erasure-value/) - [1751. Maximum Number Of Events That Can Be Attended Ii](./1751-maximum-number-of-events-that-can-be-attended-ii/) - [2040. Kth Smallest Product Of Two Sorted Arrays](./2040-kth-smallest-product-of-two-sorted-arrays/) - [2163. Minimum Difference In Sums After Removal Of Elements](./2163-minimum-difference-in-sums-after-removal-of-elements/) - [2438. Range Product Queries Of Powers](./2438-range-product-queries-of-powers/) - [3021. Alice And Bob Playing Flower Game](./3021-alice-and-bob-playing-flower-game/) - [3027. Find The Number Of Ways To Place People Ii](./3027-find-the-number-of-ways-to-place-people-ii/) - [3197. Find The Minimum Area To Cover All Ones Ii](./3197-find-the-minimum-area-to-cover-all-ones-ii/) - [3439. Reschedule Meetings For Maximum Free Time I](./3439-reschedule-meetings-for-maximum-free-time-i/) - [3477. Fruits Into Baskets Ii](./3477-fruits-into-baskets-ii/) - [3479. Fruits Into Baskets Iii](./3479-fruits-into-baskets-iii/) - [3608. Minimum Time For K Connected Components](./3608-minimum-time-for-k-connected-components/) - [3690. Split And Merge Array Transformation](./3690-split-and-merge-array-transformation/) - [3698. Split Array With Minimum Difference](./3698-split-array-with-minimum-difference/) - [3727. Maximum Alternating Sum Of Squares](./3727-maximum-alternating-sum-of-squares/)
Dynamic Programming - [0790. Domino and Tromino Tiling](./0790-domino-and-tromino-tiling/) - [1039. Minimum Score Triangulation Of Polygon](./1039-minimum-score-triangulation-of-polygon/) - [1432. Max Difference You Can Get From Changing an Integer](./1432-max-difference-you-can-get-from-changing-an-integer/) - [2787. Ways To Express An Integer As Sum Of Powers](./2787-ways-to-express-an-integer-as-sum-of-powers/) - [3202. Find The Maximum Length Of Valid Subsequence Ii](./3202-find-the-maximum-length-of-valid-subsequence-ii/) - [3573. Best Time To Buy And Sell Stock V](./3573-best-time-to-buy-and-sell-stock-v/) - [3592. Inverse Coin Change](./3592-inverse-coin-change/) - [3652. Best Time To Buy And Sell Stock Using Strategy](./3652-best-time-to-buy-and-sell-stock-using-strategy/) - [3693. Climbing Stairs Ii](./3693-climbing-stairs-ii/)
🔤 Strings
Lexicographical & Ordering
String Transformations & Operations
Palindromes & Subsequences
Vowels & Character Patterns
String Matching & Substrings
Digit & Number Strings
String Games & Encoding
File & Path Operations
Validation & Parsing
Strings & Palindromes
🌳 Trees & Graphs
🔍 Hash Tables & Dictionaries
🔢 Bit Manipulation
🔢 Pure Math
💾 System Design
📊 SQL

🤝 Contributing

While this is primarily my personal collection of solutions, I welcome any suggestions or improvements. Feel free to:

  • Report bugs or issues
  • Suggest optimizations
  • Share alternative solutions

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Solutions are automatically synced using LeetHub 3.0, a Chrome extension that automatically pushes your LeetCode solutions to GitHub.