An open API service indexing awesome lists of open source software.

https://github.com/ngkhang/leetcode-old

My collection of solutions to algorithmic problems in Leetcode
https://github.com/ngkhang/leetcode-old

data-structures-and-algorithms database dsa javascript leetcode mysql typescript

Last synced: 16 days ago
JSON representation

My collection of solutions to algorithmic problems in Leetcode

Awesome Lists containing this project

README

          

# Leetcode


logo LeetCode

> This repo is a collection of solutions to problems in LeetCode.

- This is [my profile in LeetCode](https://leetcode.com/ngkhang/), I will upload solutions for some problems regularly.

## Table of Contents

- [Leetcode](#leetcode)
- [Table of Contents](#table-of-contents)
- [Solutions](#solutions)
- [JavaScript and TypeScript](#javascript-and-typescript)
- [Database](#database)
- [References](#references)

---

## Solutions

### JavaScript and TypeScript

| Problems | Difficulty | Solutions |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [1. Two Sum](https://leetcode.com/problems/two-sum/) | ⭐ | [JS](./solutions/javascript/1-two-sum.js) - [TS](./solutions/typescript/1-two-sum.ts) |
| [13. Roman To Integer](https://leetcode.com/problems/roman-to-integer/) | ⭐ | [JS](./solutions/javascript/13-roman-to-integer.js) - [TS](./solutions/typescript/13-roman-to-integer.ts) |
| [14. Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/) | ⭐ | [JS](./solutions/javascript/14-longest-common-prefix.js) - [TS](./solutions/typescript/14-longest-common-prefix.ts) |
| [26. Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/) | ⭐ | [JS](./solutions/javascript/26-remove-duplicates-from-sorted-array.js) - [TS](./solutions/typescript/26-remove-duplicates-from-sorted-array.ts) |
| [28. Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/) | ⭐ | [JS](./solutions/javascript/28-find-the-index-of-the-first-occurrence-in-a-string.js) - [TS](./solutions/typescript/28-find-the-index-of-the-first-occurrence-in-a-string.ts) |
| [35. Search Insert Position](https://leetcode.com/problems/search-insert-position/) | ⭐ | [JS](./solutions/javascript/35-search-insert-position.js) - [TS](./solutions/typescript/35-search-insert-position.ts) |
| [58. Length of Last Word](https://leetcode.com/problems/length-of-last-word/) | ⭐ | [JS](./solutions/javascript/58-length-of-last-word.js) - [TS](./solutions/typescript/58-length-of-last-word.ts) |
| [66. Plus One](https://leetcode.com/problems/plus-one/) | ⭐ | [JS](./solutions/javascript/66-plus-one.js) - [TS](./solutions/typescript/66-plus-one.ts) |
| [67. Add Binary](https://leetcode.com/problems/add-binary/) | ⭐ | [JS](./solutions/javascript/67-add-binary.js) - [TS](./solutions/typescript/67-add-binary.ts) |
| [75. Sort Colors](https://leetcode.com/problems/sort-colors/) | ⭐ | [JS](./solutions/javascript/75-sort-colors.js) - [TS](./solutions/typescript/75-sort-colors.ts) |
| [83. Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list/) | ⭐ | [JS](./solutions/javascript/83-remove-duplicates-from-sorted-list.js) - [TS](./solutions/typescript/83-remove-duplicates-from-sorted-list.ts) |
| [88. Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/) | ⭐ | [JS](./solutions/javascript/88-merge-sorted-array.js) - [TS](./solutions/typescript/88-merge-sorted-array.ts) |
| [125. Valid Palindrome](https://leetcode.com/problems/valid-palindrome/) | ⭐ | [JS](./solutions/javascript/125-valid-palindrome.js) - [TS](./solutions/typescript/125-valid-palindrome.ts) |
| [136. Single Number](https://leetcode.com/problems/single-number/) | ⭐ | [JS](./solutions/javascript/136-single-number.js) - [TS](./solutions/typescript/136-single-number.ts) |
| [137. Single Number II](https://leetcode.com/problems/single-number-ii/) | ⭐⭐ | [JS](./solutions/javascript/137-single-number-ii.js) - [TS](./solutions/typescript/137-single-number-ii.ts) |
| [217. Contains Duplicate](https://leetcode.com/problems/contains-duplicate/) | ⭐ | [JS](./solutions/javascript/217-contains-duplicate.js) - [TS](./solutions/typescript/217-contains-duplicate.ts) |
| [219. Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii/) | ⭐ | [JS](./solutions/javascript/219-contains-duplicate-ii.js) - [TS](./solutions/typescript/219-contains-duplicate-ii.ts) |
| [242. Valid Anagram](https://leetcode.com/problems/valid-anagram/) | ⭐ | [JS](./solutions/javascript/242-valid-anagram.js) - [TS](./solutions/typescript/242-valid-anagram.ts) |
| [260. Single Number III](https://leetcode.com/problems/single-number-iii/) | ⭐⭐ | [JS](./solutions/javascript/260-single-number-iii.js) - [TS](./solutions/typescript/260-single-number-iii.ts) |
| [268. Missing Number](https://leetcode.com/problems/missing-number/) | ⭐ | [JS](./solutions/javascript/268-missing-number.js) - [TS](./solutions/typescript/268-missing-number.ts) |
| [349. Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays/) | ⭐ | [JS](./solutions/javascript/349-intersection-of-two-array.js) - [TS](./solutions/typescript/349-intersection-of-two-array.ts) |
| [350. Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii/) | ⭐ | [JS](./solutions/javascript/350-intersection-of-two-arrays-ii.js) - [TS](./solutions/typescript/350-intersection-of-two-arrays-ii.ts) |
| [367. Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square/) | ⭐ | [JS](./solutions/javascript/367-valid-perfect-square.js) - [TS](./solutions/typescript/367-valid-perfect-square.ts) |
| [383. Ransom Note](https://leetcode.com/problems/ransom-note/) | ⭐ | [JS](./solutions/javascript/383-ransom-note.js) - [TS](./solutions/typescript/383-ransom-note.ts) |
| [387. First Unique Character in a String](https://leetcode.com/problems/first-unique-character-in-a-string/) | ⭐ | [JS](./solutions/javascript/387-first-unique-character-in-a-string.js) - [TS](./solutions/typescript/387-first-unique-character-in-a-string.ts) |
| [389. Find The Difference](https://leetcode.com/problems/find-the-difference/) | ⭐ | [JS](./solutions/javascript/389-find-the-difference.js) - [TS](./solutions/typescript/389-find-the-difference.ts) |
| [415. Add Strings](https://leetcode.com/problems/add-strings/) | ⭐ | [JS](./solutions/javascript/415-add-strings.js) - [TS](./solutions/typescript/415-add-strings.ts) |
| [448. Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/) | ⭐ | [JS](./solutions/javascript/448-find-all-numbers-disappeared-in-an-array.js) - [TS](./solutions/typescript/448-find-all-numbers-disappeared-in-an-array.ts) |
| [485. Max Consecutive Ones](https://leetcode.com/problems/max-consecutive-ones/) | ⭐ | [JS](./solutions/javascript/485-max-consecutive-ones.js) - [TS](./solutions/typescript/485-max-consecutive-ones.ts) |
| [500. Keyboard Row](https://leetcode.com/problems/keyboard-row/) | ⭐ | [JS](./solutions/javascript/500-keyboard-row.js) - [TS](./solutions/typescript/500-keyboard-row.ts) |
| [717. 1-bit and 2-bit Characters](https://leetcode.com/problems/1-bit-and-2-bit-characters/) | ⭐ | [JS](./solutions/javascript/717-1-bit-and-2-bit-characters.js) - [TS](./solutions/typescript/717-1-bit-and-2-bit-characters.ts) |
| [884. Uncommon Words from Two Sentences](https://leetcode.com/problems/uncommon-words-from-two-sentences/) | ⭐ | [JS](./solutions/javascript/884-uncommon-words-from-two-sentences.js) - [TS](./solutions/typescript/884-uncommon-words-from-two-sentences.ts) |
| [989. Add To Array Form Of Integer](https://leetcode.com/problems/add-to-array-form-of-integer/) | ⭐ | [JS](./solutions/javascript/989-add-to-array-form-of-integer.js) - [TS](./solutions/typescript/989-add-to-array-form-of-integer.ts) |
| [1103. Distribute Candies to People](https://leetcode.com/problems/distribute-candies-to-people/) | ⭐ | [JS](./solutions/javascript/1103-distribute-candies-to-people.js) - [TS](./solutions/typescript/1103-distribute-candies-to-people.ts) |
| [1160. Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/) | ⭐ | [JS](./solutions/javascript/1160-find-words-that-can-be-formed-by-characters.js) - [TS](./solutions/typescript/1160-find-words-that-can-be-formed-by-characters.ts) |
| [1323. Maximum 69 Number](https://leetcode.com/problems/maximum-69-number/) | ⭐ | [JS](./solutions/javascript/1323-maximum-69-number.js) - [TS](./solutions/typescript/1323-maximum-69-number.ts) |
| [1342. Number of Steps to Reduce a Number to Zero](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/) | ⭐ | [JS](./solutions/javascript/1342-number-of-steps-to-reduce-a-number-to-zero.js) - [TS](./solutions/typescript/1342-number-of-steps-to-reduce-a-number-to-zero.ts) |
| [1437. Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away/) | ⭐ | [JS](./solutions/javascript/1437-check-if-all-1s-are-at-least-length-k-places-away.js) - [TS](./solutions/typescript/1437-check-if-all-1s-are-at-least-length-k-places-away.ts) |
| [1470. Shuffle the Array](https://leetcode.com/problems/shuffle-the-array/) | ⭐ | [JS](./solutions/javascript/1470-shuffle-the-array.js) - [TS](./solutions/typescript/1470-shuffle-the-array.ts) |
| [1716. Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank/) | ⭐ | [JS](./solutions/javascript/1716-calculate-money-in-leetcode-bank.js) - [TS](./solutions/typescript/1716-calculate-money-in-leetcode-bank.ts) |
| [1768. Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately/) | ⭐ | [JS](./solutions/javascript/1768-merge-strings-alternately.js) - [TS](./solutions/typescript/1768-merge-strings-alternately.ts) |
| [1929. Concatenation Of Array](https://leetcode.com/problems/concatenation-of-array/) | ⭐ | [JS](./solutions/javascript/1929-concatenation-of-array.js) - [TS](./solutions/typescript/1929-concatenation-of-array.ts) |
| [1980. Find Unique Binary String](https://leetcode.com/problems/find-unique-binary-string/) | ⭐ | [JS](./solutions/javascript/1980-find-unique-binary-string.js) - [TS](./solutions/typescript/1980-find-unique-binary-string.ts) |
| [2011. Final Value of Variable After Performing Operations](https://leetcode.com/problems/final-value-of-variable-after-performing-operations/) | ⭐ | [JS](./solutions/javascript/2011-final-value-of-variable-after-performing-operations.js) - [TS](./solutions/typescript/2011-final-value-of-variable-after-performing-operations.ts) |
| [2053. Kth Distinct String In An Array](https://leetcode.com/problems/kth-distinct-string-in-an-array/) | ⭐ | [JS](./solutions/javascript/2053-kth-distinct-string-in-an-array.js) - [TS](./solutions/typescript/2053-kth-distinct-string-in-an-array.ts) |
| [2139. Minimum Moves to Reach Target Score](https://leetcode.com/problems/minimum-moves-to-reach-target-score/) | ⭐⭐ | [JS](./solutions/javascript/2139-minimum-moves-to-reach-target-score.js) - [TS](./solutions/typescript/2139-minimum-moves-to-reach-target-score.ts) |
| [2169. Count Operations To Obtain Zero](https://leetcode.com/problems/count-operations-to-obtain-zero/) | ⭐ | [JS](./solutions/javascript/2169-count-operations-to-obtain-zero.js) - [TS](./solutions/typescript/2169-count-operations-to-obtain-zero.ts) |
| [2215. Find The Difference Of Two Arrays](https://leetcode.com/problems/find-the-difference-of-two-arrays/) | ⭐ | [JS](./solutions/javascript/2215-find-the-difference-of-two-arrays.js) - [TS](./solutions/typescript/2215-find-the-difference-of-two-arrays.ts) |
| [2248. Intersection Of Multiple Arrays](https://leetcode.com/problems/intersection-of-multiple-arrays/) | ⭐ | [JS](./solutions/javascript/2248-intersection-of-multiple-arrays.js) - [TS](./solutions/typescript/2248-intersection-of-multiple-arrays.ts) |
| [2351. First Letter To Appear Twice](https://leetcode.com/problems/first-letter-to-appear-twice/) | ⭐ | [JS](./solutions/javascript/2351-first-letter-to-appear-twice.js) - [TS](./solutions/typescript/2351-first-letter-to-appear-twice.ts) |
| [2399. Check Distances Between Same Letters](https://leetcode.com/problems/check-distances-between-same-letters/) | ⭐ | [JS](./solutions/javascript/2399-check-distances-between-same-letters.js) - [TS](./solutions/typescript/2399-check-distances-between-same-letters.ts) |
| [2432. The Employee That Worked on the Longest Task](https://leetcode.com/problems/the-employee-that-worked-on-the-longest-task/) | ⭐ | [JS](./solutions/javascript/2432-the-employee-that-worked-on-the-longest-task.js) - [TS](./solutions/typescript/2432-the-employee-that-worked-on-the-longest-task.ts) |
| [2460. Apply Operations to an Array](https://leetcode.com/problems/apply-operations-to-an-array/) | ⭐ | [JS](./solutions/javascript/2460-apply-operations-to-an-array.js) - [TS](./solutions/typescript/2460-apply-operations-to-an-array.ts) |
| [3065. Minimum Operations to Exceed Threshold Value I](https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-i/) | ⭐ | [JS](./solutions/javascript/3065-minimum-operations-to-exceed-threshold-value-i.js) - [TS](./solutions/typescript/3065-minimum-operations-to-exceed-threshold-value-i.ts) |
| [3289. The Two Sneaky Numbers of Digitville](https://leetcode.com/problems/the-two-sneaky-numbers-of-digitville/) | ⭐ | [JS](./solutions/javascript/3289-the-two-sneaky-numbers-of-digitville.js) - [TS](./solutions/typescript/3289-the-two-sneaky-numbers-of-digitville.ts) |

### Database

| Problems | Difficulty | Solutions |
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------- |
| [181. Employees Earning More Than Their Managers](https://leetcode.com/problems/employees-earning-more-than-their-managers/) | ⭐ | [📝](./solutions/database/181-employees-earning-more-than-their-managers.sql) |
| [182. Duplicate Emails](https://leetcode.com/problems/duplicate-emails/) | ⭐ | [📝](./solutions/database/182-duplicate-emails.sql) |
| [183. Customers Who Never Order](https://leetcode.com/problems/customers-who-never-order/) | ⭐ | [📝](./solutions/database/183-customers-who-never-order.sql) |
| [196. Delete Duplicate Emails](https://leetcode.com/problems/delete-duplicate-emails/) | ⭐ | [📝](./solutions/database/196-delete-duplicate-emails.sql) |
| [197. Rising Temperature](https://leetcode.com/problems/rising-temperature/) | ⭐ | [📝](./solutions/database/197-rising-temperature.sql) |
| [511. Game Play Analysis I](https://leetcode.com/problems/game-play-analysis-i/) | ⭐ | [📝](./solutions/database/511-game-play-analysis-i.sql) |
| [577. Employee Bonus](https://leetcode.com/problems/employee-bonus/) | ⭐ | [📝](./solutions/database/577-employee-bonus.sql) |
| [584. Find Customer Referee](https://leetcode.com/problems/find-customer-referee/) | ⭐ | [📝](./solutions/database/584-find-customer-referee.sql) |
| [586. Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/) | ⭐ | [📝](./solutions/database/586-customer-placing-the-largest-number-of-orders.sql) |
| [595. Big Countries](https://leetcode.com/problems/big-countries/) | ⭐ | [📝](./solutions/database/595-big-countries.sql) |
| [596. Classes More Than 5 Students](https://leetcode.com/problems/classes-with-at-least-5-students/) | ⭐ | [📝](./solutions/database/596-classes-with-at-least-5-students.sql) |
| [610. Triangle Judgement](https://leetcode.com/problems/triangle-judgement/) | ⭐ | [📝](./solutions/database/610-triangle-judgement.sql) |
| [620. Not Boring Movies](https://leetcode.com/problems/not-boring-movies/) | ⭐ | [📝](./solutions/database/620-not-boring-movies.sql) |
| [627. Swap Salary](https://leetcode.com/problems/swap-salary/) | ⭐ | [📝](./solutions/database/627-swap-salary.sql) |
| [1068. Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i/) | ⭐ | [📝](./solutions/database/1068-product-sales-analysis-i.sql) |
| [1075. Project Employees I](https://leetcode.com/problems/project-employees-i) | ⭐ | [📝](./solutions/database/1075-project-employees-i.sql) |
| [1148. Article Views I](https://leetcode.com/problems/article-views-i/) | ⭐ | [📝](./solutions/database/1148-article-views-i.sql) |
| [1683. Invalid Tweets](https://leetcode.com/problems/invalid-tweets/) | ⭐ | [📝](./solutions/database/1683-invalid-tweets.sql) |
| [1731. The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee/) | ⭐ | [📝](./solutions/database/1731-the-number-of-employees-which-report-to-each-employee.sql) |
| [1741. Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee/) | ⭐ | [📝](./solutions/database/1741-find-total-time-spent-by-each-employee.sql) |
| [1757. Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products/) | ⭐ | [📝](./solutions/database/1757-recyclable-and-low-fat-products.sql) |
| [3436. Find Valid Emails](https://leetcode.com/problems/find-valid-emails/) | ⭐ | [📝](./solutions/database/3436-find-valid-emails.sql) |

---

## References

- [🔗 Big-O cheat sheet](https://www.bigocheatsheet.com/)
- Visualizations
- [🔗 Visualgo](https://visualgo.net/en)
- [🔗 Data Structure Visualizations](https://www.cs.usfca.edu/~galles/visualization/Algorithms.html)

[⬆️ Scroll top](#leetcode)