From 6fd0c8fb85638e52ad353869b193ad5644dc6b3a Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 1 Dec 2023 23:23:21 +0200 Subject: [PATCH 01/49] Updated readme --- README.md | 260 +++++++++++++++++++++++++++--------------------------- 1 file changed, 130 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index 097fc5c..89623de 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) ## -* [Algorithm II](#algorithm-ii) * [Binary Search I](#binary-search-i) * [Binary Search II](#binary-search-ii) * [Dynamic Programming I](#dynamic-programming-i) @@ -26,135 +25,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. * [Data Structure I](#data-structure-i) * [Data Structure II](#data-structure-ii) * [Algorithm I](#algorithm-i) - -### Algorithm II - -#### Day 1 Binary Search - -| | | | | | -|-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 - -#### Day 2 Binary Search - -| | | | | | -|-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 - -#### Day 3 Two Pointers - -| | | | | | -|-|-|-|-|-|- -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 - -#### Day 4 Two Pointers - -| | | | | | -|-|-|-|-|-|- -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 - -#### Day 5 Sliding Window - -| | | | | | -|-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 - -#### Day 6 Breadth First Search Depth First Search - -| | | | | | -|-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 - -#### Day 7 Breadth First Search Depth First Search - -| | | | | | -|-|-|-|-|-|- - -#### Day 8 Breadth First Search Depth First Search - -| | | | | | -|-|-|-|-|-|- - -#### Day 9 Recursion Backtracking - -| | | | | | -|-|-|-|-|-|- -| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 - -#### Day 10 Recursion Backtracking - -| | | | | | -|-|-|-|-|-|- -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 - -#### Day 11 Recursion Backtracking - -| | | | | | -|-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 -| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 - -#### Day 12 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 - -#### Day 13 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 - -#### Day 14 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 - -#### Day 15 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 - -#### Day 16 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 - -#### Day 17 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 - -#### Day 18 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 - -#### Day 19 Bit Manipulation - -| | | | | | -|-|-|-|-|-|- - -#### Day 20 Others - -| | | | | | -|-|-|-|-|-|- - -#### Day 21 Others - -| | | | | | -|-|-|-|-|-|- +* [Algorithm II](#algorithm-ii) ### Binary Search I @@ -1408,6 +1279,135 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +### Algorithm II + +#### Day 1 Binary Search + +| | | | | | +|-|-|-|-|-|- +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 + +#### Day 2 Binary Search + +| | | | | | +|-|-|-|-|-|- +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 + +#### Day 3 Two Pointers + +| | | | | | +|-|-|-|-|-|- +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 + +#### Day 4 Two Pointers + +| | | | | | +|-|-|-|-|-|- +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 + +#### Day 5 Sliding Window + +| | | | | | +|-|-|-|-|-|- +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 + +#### Day 6 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 + +#### Day 7 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- + +#### Day 8 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- + +#### Day 9 Recursion Backtracking + +| | | | | | +|-|-|-|-|-|- +| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 + +#### Day 10 Recursion Backtracking + +| | | | | | +|-|-|-|-|-|- +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 + +#### Day 11 Recursion Backtracking + +| | | | | | +|-|-|-|-|-|- +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 +| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 + +#### Day 12 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 + +#### Day 13 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 + +#### Day 14 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 + +#### Day 15 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 + +#### Day 16 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 + +#### Day 17 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 + +#### Day 18 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 + +#### Day 19 Bit Manipulation + +| | | | | | +|-|-|-|-|-|- + +#### Day 20 Others + +| | | | | | +|-|-|-|-|-|- + +#### Day 21 Others + +| | | | | | +|-|-|-|-|-|- + ## Algorithms | # | Title | Difficulty | Tag | Time, ms | Time, % From 90bd70b9ba491311473d6c96d1bef346eb77c8b5 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 1 Dec 2023 23:29:17 +0200 Subject: [PATCH 02/49] Version 1.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bcda721..c41535e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@javadev/leetcode-in-typescript", - "version": "1.1.0", + "version": "1.2.0", "description": "TypeScript-based LeetCode algorithm problem solutions, regularly updated", "keywords": [ "algorithm", From 805362bb8cc392b6dbf26a77a2ebf57a70f177aa Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Mon, 1 Jan 2024 21:27:17 +0200 Subject: [PATCH 03/49] Updated readme --- README.md | 136 +++++++++++++++++++++++++-------------------------- package.json | 2 +- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 89623de..7303911 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) ## -* [Binary Search I](#binary-search-i) * [Binary Search II](#binary-search-ii) * [Dynamic Programming I](#dynamic-programming-i) * [Programming Skills I](#programming-skills-i) @@ -26,73 +25,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. * [Data Structure II](#data-structure-ii) * [Algorithm I](#algorithm-i) * [Algorithm II](#algorithm-ii) - -### Binary Search I - -#### Day 1 - -| | | | | | -|-|-|-|-|-|- - -#### Day 2 - -| | | | | | -|-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 - -#### Day 3 - -| | | | | | -|-|-|-|-|-|- - -#### Day 4 - -| | | | | | -|-|-|-|-|-|- - -#### Day 5 - -| | | | | | -|-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 - -#### Day 6 - -| | | | | | -|-|-|-|-|-|- - -#### Day 7 - -| | | | | | -|-|-|-|-|-|- - -#### Day 8 - -| | | | | | -|-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 - -#### Day 9 - -| | | | | | -|-|-|-|-|-|- - -#### Day 10 - -| | | | | | -|-|-|-|-|-|- - -#### Day 11 - -| | | | | | -|-|-|-|-|-|- -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 - -#### Day 12 - -| | | | | | -|-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +* [Binary Search I](#binary-search-i) ### Binary Search II @@ -1408,6 +1341,73 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +### Binary Search I + +#### Day 1 + +| | | | | | +|-|-|-|-|-|- + +#### Day 2 + +| | | | | | +|-|-|-|-|-|- +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 + +#### Day 3 + +| | | | | | +|-|-|-|-|-|- + +#### Day 4 + +| | | | | | +|-|-|-|-|-|- + +#### Day 5 + +| | | | | | +|-|-|-|-|-|- +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 + +#### Day 6 + +| | | | | | +|-|-|-|-|-|- + +#### Day 7 + +| | | | | | +|-|-|-|-|-|- + +#### Day 8 + +| | | | | | +|-|-|-|-|-|- +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 + +#### Day 9 + +| | | | | | +|-|-|-|-|-|- + +#### Day 10 + +| | | | | | +|-|-|-|-|-|- + +#### Day 11 + +| | | | | | +|-|-|-|-|-|- +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 + +#### Day 12 + +| | | | | | +|-|-|-|-|-|- +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 + ## Algorithms | # | Title | Difficulty | Tag | Time, ms | Time, % diff --git a/package.json b/package.json index c41535e..016f0ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@javadev/leetcode-in-typescript", - "version": "1.2.0", + "version": "1.3.0", "description": "TypeScript-based LeetCode algorithm problem solutions, regularly updated", "keywords": [ "algorithm", From 51bdce50be753814762142b2ddcf849ce44e69fb Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sat, 13 Jan 2024 15:25:18 +0200 Subject: [PATCH 04/49] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 04ac570..5bebe5b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Valentyn Kolesnikov +Copyright (c) 2023-2024 Valentyn Kolesnikov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 1e68cc0480c8cb7a60d907a1feea4322eb3681ee Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 1 Feb 2024 07:34:23 +0200 Subject: [PATCH 05/49] Updated readme --- README.md | 212 +++++++++++++++++++++++++++--------------------------- 1 file changed, 106 insertions(+), 106 deletions(-) diff --git a/README.md b/README.md index 7303911..1ae5524 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) ## -* [Binary Search II](#binary-search-ii) * [Dynamic Programming I](#dynamic-programming-i) * [Programming Skills I](#programming-skills-i) * [Programming Skills II](#programming-skills-ii) @@ -26,111 +25,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. * [Algorithm I](#algorithm-i) * [Algorithm II](#algorithm-ii) * [Binary Search I](#binary-search-i) - -### Binary Search II - -#### Day 1 - -| | | | | | -|-|-|-|-|-|- - -#### Day 2 - -| | | | | | -|-|-|-|-|-|- - -#### Day 3 - -| | | | | | -|-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 - -#### Day 4 - -| | | | | | -|-|-|-|-|-|- - -#### Day 5 - -| | | | | | -|-|-|-|-|-|- -| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 - -#### Day 6 - -| | | | | | -|-|-|-|-|-|- - -#### Day 7 - -| | | | | | -|-|-|-|-|-|- - -#### Day 8 - -| | | | | | -|-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 - -#### Day 9 - -| | | | | | -|-|-|-|-|-|- - -#### Day 10 - -| | | | | | -|-|-|-|-|-|- - -#### Day 11 - -| | | | | | -|-|-|-|-|-|- - -#### Day 12 - -| | | | | | -|-|-|-|-|-|- - -#### Day 13 - -| | | | | | -|-|-|-|-|-|- - -#### Day 14 - -| | | | | | -|-|-|-|-|-|- - -#### Day 15 - -| | | | | | -|-|-|-|-|-|- - -#### Day 16 - -| | | | | | -|-|-|-|-|-|- - -#### Day 17 - -| | | | | | -|-|-|-|-|-|- - -#### Day 18 - -| | | | | | -|-|-|-|-|-|- - -#### Day 19 - -| | | | | | -|-|-|-|-|-|- - -#### Day 20 - -| | | | | | -|-|-|-|-|-|- +* [Binary Search II](#binary-search-ii) ### Dynamic Programming I @@ -1408,6 +1303,111 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +### Binary Search II + +#### Day 1 + +| | | | | | +|-|-|-|-|-|- + +#### Day 2 + +| | | | | | +|-|-|-|-|-|- + +#### Day 3 + +| | | | | | +|-|-|-|-|-|- +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 + +#### Day 4 + +| | | | | | +|-|-|-|-|-|- + +#### Day 5 + +| | | | | | +|-|-|-|-|-|- +| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 + +#### Day 6 + +| | | | | | +|-|-|-|-|-|- + +#### Day 7 + +| | | | | | +|-|-|-|-|-|- + +#### Day 8 + +| | | | | | +|-|-|-|-|-|- +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 + +#### Day 9 + +| | | | | | +|-|-|-|-|-|- + +#### Day 10 + +| | | | | | +|-|-|-|-|-|- + +#### Day 11 + +| | | | | | +|-|-|-|-|-|- + +#### Day 12 + +| | | | | | +|-|-|-|-|-|- + +#### Day 13 + +| | | | | | +|-|-|-|-|-|- + +#### Day 14 + +| | | | | | +|-|-|-|-|-|- + +#### Day 15 + +| | | | | | +|-|-|-|-|-|- + +#### Day 16 + +| | | | | | +|-|-|-|-|-|- + +#### Day 17 + +| | | | | | +|-|-|-|-|-|- + +#### Day 18 + +| | | | | | +|-|-|-|-|-|- + +#### Day 19 + +| | | | | | +|-|-|-|-|-|- + +#### Day 20 + +| | | | | | +|-|-|-|-|-|- + ## Algorithms | # | Title | Difficulty | Tag | Time, ms | Time, % From bac21a80485d2ea552d7744a84e0409deeec11d9 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Wed, 1 May 2024 06:19:22 -0400 Subject: [PATCH 06/49] Updated readme --- README.md | 886 +++++++++++++++++++++++++-------------------------- package.json | 2 +- 2 files changed, 444 insertions(+), 444 deletions(-) diff --git a/README.md b/README.md index 1ae5524..3006414 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) ## -* [Dynamic Programming I](#dynamic-programming-i) -* [Programming Skills I](#programming-skills-i) -* [Programming Skills II](#programming-skills-ii) * [Graph Theory I](#graph-theory-i) * [SQL I](#sql-i) * [Level 1](#level-1) @@ -26,1284 +23,1283 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. * [Algorithm II](#algorithm-ii) * [Binary Search I](#binary-search-i) * [Binary Search II](#binary-search-ii) +* [Dynamic Programming I](#dynamic-programming-i) +* [Programming Skills I](#programming-skills-i) +* [Programming Skills II](#programming-skills-ii) -### Dynamic Programming I +### Graph Theory I -#### Day 1 +#### Day 1 Matrix Related Problems | | | | | | |-|-|-|-|-|- +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 2 +#### Day 2 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -#### Day 3 +#### Day 3 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -#### Day 4 +#### Day 4 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -#### Day 5 +#### Day 5 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 -#### Day 6 +#### Day 6 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -#### Day 7 +#### Day 7 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -#### Day 8 +#### Day 8 Standard Traversal | | | | | | |-|-|-|-|-|- -#### Day 9 +#### Day 9 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 -#### Day 10 +#### Day 10 Standard Traversal | | | | | | |-|-|-|-|-|- -#### Day 11 +#### Day 11 Breadth First Search | | | | | | |-|-|-|-|-|- -| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 -#### Day 12 +#### Day 12 Breadth First Search | | | | | | |-|-|-|-|-|- -#### Day 13 +#### Day 13 Graph Theory | | | | | | |-|-|-|-|-|- -#### Day 14 +#### Day 14 Graph Theory | | | | | | |-|-|-|-|-|- -#### Day 15 - -| | | | | | -|-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 +### SQL I -#### Day 16 +#### Day 1 Select | | | | | | |-|-|-|-|-|- -| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 -| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 -#### Day 17 +#### Day 2 Select and Order | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 18 +#### Day 3 String Processing Functions | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Day 19 +#### Day 4 Union and Select | | | | | | |-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -#### Day 20 +#### Day 5 Union | | | | | | |-|-|-|-|-|- -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -#### Day 21 +#### Day 6 Union | | | | | | |-|-|-|-|-|- -### Programming Skills I - -#### Day 1 Basic Data Type +#### Day 7 Function | | | | | | |-|-|-|-|-|- -#### Day 2 Operator +#### Day 8 Function | | | | | | |-|-|-|-|-|- -#### Day 3 Conditional Statements +#### Day 9 Control of Flow | | | | | | |-|-|-|-|-|- -#### Day 4 Loop +#### Day 10 Where | | | | | | |-|-|-|-|-|- -#### Day 5 Function - -| | | | | | -|-|-|-|-|-|- +### Level 1 -#### Day 6 Array +#### Day 1 Prefix Sum | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -#### Day 7 Array +#### Day 2 String | | | | | | |-|-|-|-|-|- -#### Day 8 String +#### Day 3 Linked List | | | | | | |-|-|-|-|-|- +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -#### Day 9 String +#### Day 4 Linked List | | | | | | |-|-|-|-|-|- +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -#### Day 10 Linked List and Tree +#### Day 5 Greedy | | | | | | |-|-|-|-|-|- -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -#### Day 11 Containers and Libraries +#### Day 6 Tree | | | | | | |-|-|-|-|-|- +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -#### Day 12 Class and Object +#### Day 7 Binary Search | | | | | | |-|-|-|-|-|- -### Programming Skills II - -#### Day 1 +#### Day 8 Binary Search Tree | | | | | | |-|-|-|-|-|- +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -#### Day 2 +#### Day 9 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 3 +#### Day 10 Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -#### Day 4 +#### Day 11 Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -#### Day 5 +#### Day 12 Sliding Window/Two Pointer | | | | | | |-|-|-|-|-|- +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 -#### Day 6 +#### Day 13 Hashmap | | | | | | |-|-|-|-|-|- -| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 194 | 97.36 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 -#### Day 7 +#### Day 14 Stack | | | | | | |-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 -#### Day 8 +#### Day 15 Heap | | | | | | |-|-|-|-|-|- -#### Day 9 +### Level 2 + +#### Day 1 Implementation/Simulation | | | | | | |-|-|-|-|-|- -#### Day 10 +#### Day 2 String | | | | | | |-|-|-|-|-|- -#### Day 11 +#### Day 3 Linked List | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 -#### Day 12 +#### Day 4 Linked List | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 +| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 -#### Day 13 +#### Day 5 Greedy | | | | | | |-|-|-|-|-|- -#### Day 14 +#### Day 6 Tree | | | | | | |-|-|-|-|-|- -| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -#### Day 15 +#### Day 7 Tree | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 +| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 +| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 -#### Day 16 +#### Day 8 Binary Search | | | | | | |-|-|-|-|-|- +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -#### Day 17 +#### Day 9 Binary Search Tree | | | | | | |-|-|-|-|-|- +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 -#### Day 18 +#### Day 10 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -#### Day 19 +#### Day 11 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -#### Day 20 +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -### Graph Theory I - -#### Day 1 Matrix Related Problems +#### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 91 | 74.38 +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -#### Day 2 Matrix Related Problems +#### Day 14 Sliding Window/Two Pointer | | | | | | |-|-|-|-|-|- +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 +| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 -#### Day 3 Matrix Related Problems +#### Day 15 Tree | | | | | | |-|-|-|-|-|- +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 -#### Day 4 Matrix Related Problems +#### Day 16 Design | | | | | | |-|-|-|-|-|- +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 -#### Day 5 Matrix Related Problems +#### Day 17 Interval | | | | | | |-|-|-|-|-|- +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Day 6 Matrix Related Problems +#### Day 18 Stack | | | | | | |-|-|-|-|-|- -#### Day 7 Standard Traversal +#### Day 19 Union Find | | | | | | |-|-|-|-|-|- -#### Day 8 Standard Traversal +#### Day 20 Brute Force/Backtracking | | | | | | |-|-|-|-|-|- +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -#### Day 9 Standard Traversal +### Udemy + +#### Udemy Integers | | | | | | |-|-|-|-|-|- +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +| 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 56 | 95.68 +| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 137 | 88.64 -#### Day 10 Standard Traversal +#### Udemy Strings | | | | | | |-|-|-|-|-|- +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -#### Day 11 Breadth First Search +#### Udemy Binary Search | | | | | | |-|-|-|-|-|- +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -#### Day 12 Breadth First Search +#### Udemy Arrays | | | | | | |-|-|-|-|-|- +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 +| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 55 | 98.51 +| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 -#### Day 13 Graph Theory +#### Udemy Two Pointers | | | | | | |-|-|-|-|-|- +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -#### Day 14 Graph Theory +#### Udemy Famous Algorithm | | | | | | |-|-|-|-|-|- +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 -### SQL I - -#### Day 1 Select +#### Udemy Sorting Algorithms | | | | | | |-|-|-|-|-|- -#### Day 2 Select and Order +#### Udemy 2D Arrays/Matrix | | | | | | |-|-|-|-|-|- +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 +| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Day 3 String Processing Functions +#### Udemy Linked List | | | | | | |-|-|-|-|-|- +| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 +| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 +| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 + +#### Udemy Tree Stack Queue -#### Day 4 Union and Select - | | | | | | |-|-|-|-|-|- +| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 -#### Day 5 Union +#### Udemy Trie and Heap | | | | | | |-|-|-|-|-|- +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 -#### Day 6 Union +#### Udemy Graph | | | | | | |-|-|-|-|-|- +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 7 Function +#### Udemy Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 -#### Day 8 Function +#### Udemy Backtracking/Recursion | | | | | | |-|-|-|-|-|- +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 +| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -#### Day 9 Control of Flow +#### Udemy Bit Manipulation | | | | | | |-|-|-|-|-|- +| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Top_100_Liked_Questions, Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 -#### Day 10 Where +#### Udemy Design | | | | | | |-|-|-|-|-|- +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -### Level 1 +### Data Structure I -#### Day 1 Prefix Sum +#### Day 1 Array | | | | | | |-|-|-|-|-|- +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 -#### Day 2 String +#### Day 2 Array | | | | | | |-|-|-|-|-|- +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 -#### Day 3 Linked List +#### Day 3 Array | | | | | | |-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -#### Day 4 Linked List +#### Day 4 Array | | | | | | |-|-|-|-|-|- -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -#### Day 5 Greedy +#### Day 5 Array | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Day 6 Tree +#### Day 6 String | | | | | | |-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -#### Day 7 Binary Search +#### Day 7 Linked List | | | | | | |-|-|-|-|-|- +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -#### Day 8 Binary Search Tree +#### Day 8 Linked List | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -#### Day 9 Graph/BFS/DFS +#### Day 9 Stack Queue | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 -#### Day 10 Dynamic Programming +#### Day 10 Tree | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 -#### Day 11 Dynamic Programming +#### Day 11 Tree | | | | | | |-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 -#### Day 12 Sliding Window/Two Pointer +#### Day 12 Tree | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -#### Day 13 Hashmap +#### Day 13 Tree | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 -#### Day 14 Stack +#### Day 14 Tree | | | | | | |-|-|-|-|-|- -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -#### Day 15 Heap +### Data Structure II + +#### Day 1 Array | | | | | | |-|-|-|-|-|- +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -### Level 2 - -#### Day 1 Implementation/Simulation +#### Day 2 Array | | | | | | |-|-|-|-|-|- +| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Day 2 String +#### Day 3 Array | | | | | | |-|-|-|-|-|- +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -#### Day 3 Linked List +#### Day 4 Array | | | | | | |-|-|-|-|-|- -| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 -#### Day 4 Linked List +#### Day 5 Array | | | | | | |-|-|-|-|-|- -| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 70 | 92.45 -#### Day 5 Greedy +#### Day 6 String | | | | | | |-|-|-|-|-|- -#### Day 6 Tree +#### Day 7 String | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 54 | 94.74 -#### Day 7 Tree +#### Day 8 String | | | | | | |-|-|-|-|-|- -| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 -| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -#### Day 8 Binary Search +#### Day 9 String | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 9 Binary Search Tree +#### Day 10 Linked List | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -#### Day 10 Graph/BFS/DFS +#### Day 11 Linked List | | | | | | |-|-|-|-|-|- +| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 -#### Day 11 Graph/BFS/DFS +#### Day 12 Linked List | | | | | | |-|-|-|-|-|- +| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 -#### Day 12 Dynamic Programming +#### Day 13 Linked List | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 -#### Day 13 Dynamic Programming +#### Day 14 Stack Queue | | | | | | |-|-|-|-|-|- -| 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 91 | 74.38 -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -#### Day 14 Sliding Window/Two Pointer +#### Day 15 Tree | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 -| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 -#### Day 15 Tree +#### Day 16 Tree | | | | | | |-|-|-|-|-|- -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 -#### Day 16 Design +#### Day 17 Tree | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 -#### Day 17 Interval +#### Day 18 Tree | | | | | | |-|-|-|-|-|- -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 -#### Day 18 Stack +#### Day 19 Graph | | | | | | |-|-|-|-|-|- -#### Day 19 Union Find +#### Day 20 Heap Priority Queue | | | | | | |-|-|-|-|-|- +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 +| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 -#### Day 20 Brute Force/Backtracking +#### Day 21 Heap Priority Queue | | | | | | |-|-|-|-|-|- -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -### Udemy +### Algorithm I -#### Udemy Integers +#### Day 1 Binary Search | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -| 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 56 | 95.68 -| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 137 | 88.64 +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 -#### Udemy Strings +#### Day 2 Two Pointers | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 -#### Udemy Binary Search +#### Day 3 Two Pointers | | | | | | |-|-|-|-|-|- -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -#### Udemy Arrays +#### Day 4 Two Pointers | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 55 | 98.51 -| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 -#### Udemy Two Pointers +#### Day 5 Two Pointers | | | | | | |-|-|-|-|-|- -| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 -#### Udemy Famous Algorithm +#### Day 6 Sliding Window | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 -#### Udemy Sorting Algorithms +#### Day 7 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -#### Udemy 2D Arrays/Matrix +#### Day 8 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Udemy Linked List +#### Day 9 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- + +#### Day 10 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 -| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 -| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 -| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -#### Udemy Tree Stack Queue +#### Day 11 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -#### Udemy Trie and Heap +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -#### Udemy Graph +#### Day 13 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Udemy Dynamic Programming +#### Day 14 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -#### Udemy Backtracking/Recursion +### Algorithm II + +#### Day 1 Binary Search | | | | | | |-|-|-|-|-|- -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Udemy Bit Manipulation +#### Day 2 Binary Search | | | | | | |-|-|-|-|-|- -| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Top_100_Liked_Questions, Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -#### Udemy Design +#### Day 3 Two Pointers | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -### Data Structure I +#### Day 4 Two Pointers -#### Day 1 Array +| | | | | | +|-|-|-|-|-|- +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 + +#### Day 5 Sliding Window | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 -#### Day 2 Array +#### Day 6 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 3 Array +#### Day 7 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -#### Day 4 Array +#### Day 8 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -#### Day 5 Array +#### Day 9 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 -#### Day 6 String +#### Day 10 Recursion Backtracking | | | | | | |-|-|-|-|-|- +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -#### Day 7 Linked List +#### Day 11 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 +| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 -#### Day 8 Linked List +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -#### Day 9 Stack Queue +#### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -#### Day 10 Tree +#### Day 14 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 11 Tree +#### Day 15 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -#### Day 12 Tree +#### Day 16 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Day 13 Tree +#### Day 17 Dynamic Programming | | | | | | |-|-|-|-|-|- +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -#### Day 14 Tree +#### Day 18 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 - -### Data Structure II +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -#### Day 1 Array +#### Day 19 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -#### Day 2 Array +#### Day 20 Others | | | | | | |-|-|-|-|-|- -| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Day 3 Array +#### Day 21 Others | | | | | | |-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -#### Day 4 Array +### Binary Search I + +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 -#### Day 5 Array +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 70 | 92.45 +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 -#### Day 6 String +#### Day 3 | | | | | | |-|-|-|-|-|- -#### Day 7 String +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 54 | 94.74 -#### Day 8 String +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 -#### Day 9 String +#### Day 6 | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 10 Linked List +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -#### Day 11 Linked List +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Day 12 Linked List +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 -#### Day 13 Linked List +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 -#### Day 14 Stack Queue +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -#### Day 15 Tree +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -#### Day 16 Tree +### Binary Search II + +#### Day 1 | | | | | | |-|-|-|-|-|- -#### Day 17 Tree +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 -#### Day 18 Tree +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Day 19 Graph +#### Day 4 | | | | | | |-|-|-|-|-|- -#### Day 20 Heap Priority Queue +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 -| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 +| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 -#### Day 21 Heap Priority Queue +#### Day 6 | | | | | | |-|-|-|-|-|- -### Algorithm I - -#### Day 1 Binary Search +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 -#### Day 2 Two Pointers +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 -#### Day 3 Two Pointers +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -#### Day 4 Two Pointers +#### Day 10 | | | | | | |-|-|-|-|-|- -#### Day 5 Two Pointers +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 -#### Day 6 Sliding Window +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 -#### Day 7 Breadth First Search Depth First Search +#### Day 13 | | | | | | |-|-|-|-|-|- -#### Day 8 Breadth First Search Depth First Search +#### Day 14 | | | | | | |-|-|-|-|-|- -#### Day 9 Breadth First Search Depth First Search +#### Day 15 | | | | | | |-|-|-|-|-|- -#### Day 10 Recursion Backtracking +#### Day 16 | | | | | | |-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -#### Day 11 Recursion Backtracking +#### Day 17 | | | | | | |-|-|-|-|-|- -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -#### Day 12 Dynamic Programming +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -#### Day 13 Bit Manipulation +#### Day 19 | | | | | | |-|-|-|-|-|- -#### Day 14 Bit Manipulation +#### Day 20 | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -### Algorithm II +### Dynamic Programming I -#### Day 1 Binary Search +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Day 2 Binary Search +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -#### Day 3 Two Pointers +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -#### Day 4 Two Pointers +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -#### Day 5 Sliding Window +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 -#### Day 6 Breadth First Search Depth First Search +#### Day 6 | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -#### Day 7 Breadth First Search Depth First Search +#### Day 7 | | | | | | |-|-|-|-|-|- +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -#### Day 8 Breadth First Search Depth First Search +#### Day 8 | | | | | | |-|-|-|-|-|- -#### Day 9 Recursion Backtracking +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 -#### Day 10 Recursion Backtracking +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -#### Day 11 Recursion Backtracking +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 -| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 +| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 -#### Day 12 Dynamic Programming +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -#### Day 13 Dynamic Programming +#### Day 13 | | | | | | |-|-|-|-|-|- -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -#### Day 14 Dynamic Programming +#### Day 14 | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 15 Dynamic Programming +#### Day 15 | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -#### Day 16 Dynamic Programming +#### Day 16 | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 +| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 -#### Day 17 Dynamic Programming +#### Day 17 | | | | | | |-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 18 Dynamic Programming +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Day 19 Bit Manipulation +#### Day 19 | | | | | | |-|-|-|-|-|- +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -#### Day 20 Others +#### Day 20 | | | | | | |-|-|-|-|-|- +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -#### Day 21 Others +#### Day 21 | | | | | | |-|-|-|-|-|- -### Binary Search I +### Programming Skills I -#### Day 1 +#### Day 1 Basic Data Type | | | | | | |-|-|-|-|-|- -#### Day 2 +#### Day 2 Operator | | | | | | |-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 -#### Day 3 +#### Day 3 Conditional Statements | | | | | | |-|-|-|-|-|- -#### Day 4 +#### Day 4 Loop | | | | | | |-|-|-|-|-|- -#### Day 5 +#### Day 5 Function | | | | | | |-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 -#### Day 6 +#### Day 6 Array | | | | | | |-|-|-|-|-|- +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -#### Day 7 +#### Day 7 Array | | | | | | |-|-|-|-|-|- -#### Day 8 +#### Day 8 String | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Day 9 +#### Day 9 String | | | | | | |-|-|-|-|-|- -#### Day 10 +#### Day 10 Linked List and Tree | | | | | | |-|-|-|-|-|- +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -#### Day 11 +#### Day 11 Containers and Libraries | | | | | | |-|-|-|-|-|- -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -#### Day 12 +#### Day 12 Class and Object | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -### Binary Search II +### Programming Skills II #### Day 1 @@ -1319,7 +1315,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 #### Day 4 @@ -1330,23 +1325,23 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 #### Day 6 | | | | | | |-|-|-|-|-|- +| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 194 | 97.36 #### Day 7 | | | | | | |-|-|-|-|-|- +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 #### Day 8 | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 #### Day 9 @@ -1362,11 +1357,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 #### Day 12 | | | | | | |-|-|-|-|-|- +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 #### Day 13 @@ -1377,11 +1374,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 #### Day 15 | | | | | | |-|-|-|-|-|- +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 #### Day 16 @@ -1397,6 +1396,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 #### Day 19 diff --git a/package.json b/package.json index 016f0ef..13a3b1f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@javadev/leetcode-in-typescript", - "version": "1.3.0", + "version": "1.4.0", "description": "TypeScript-based LeetCode algorithm problem solutions, regularly updated", "keywords": [ "algorithm", From 606d32957b6ff526b23db12a9d2a8abc55e5ced2 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sun, 28 Jul 2024 11:03:42 +0300 Subject: [PATCH 07/49] Node 20 --- .github/workflows/node.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 4267b85..b2e691e 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -10,17 +10,17 @@ jobs: unitTest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup node uses: actions/setup-node@v3 with: - node-version: '16.x' + node-version: '20.x' - name: Setup pnpm - uses: pnpm/action-setup@v2.4.0 + uses: pnpm/action-setup@v4.0.0 with: version: 8.8.0 From 1d0f7de84a09b075dd1bb90e773bd94363d85670 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 11 Oct 2024 13:14:43 +0300 Subject: [PATCH 08/49] Updated readme --- README.md | 924 +++++++++++++++++++++++++++--------------------------- 1 file changed, 462 insertions(+), 462 deletions(-) diff --git a/README.md b/README.md index 3006414..a36c840 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) ## -* [Graph Theory I](#graph-theory-i) -* [SQL I](#sql-i) -* [Level 1](#level-1) -* [Level 2](#level-2) -* [Udemy](#udemy) * [Data Structure I](#data-structure-i) * [Data Structure II](#data-structure-ii) * [Algorithm I](#algorithm-i) @@ -26,1387 +21,1392 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. * [Dynamic Programming I](#dynamic-programming-i) * [Programming Skills I](#programming-skills-i) * [Programming Skills II](#programming-skills-ii) +* [Graph Theory I](#graph-theory-i) +* [SQL I](#sql-i) +* [Level 1](#level-1) +* [Level 2](#level-2) +* [Udemy](#udemy) -### Graph Theory I +### Data Structure I -#### Day 1 Matrix Related Problems +#### Day 1 Array | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 -#### Day 2 Matrix Related Problems +#### Day 2 Array | | | | | | |-|-|-|-|-|- +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 -#### Day 3 Matrix Related Problems +#### Day 3 Array | | | | | | |-|-|-|-|-|- +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -#### Day 4 Matrix Related Problems +#### Day 4 Array | | | | | | |-|-|-|-|-|- -#### Day 5 Matrix Related Problems +#### Day 5 Array | | | | | | |-|-|-|-|-|- +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Day 6 Matrix Related Problems +#### Day 6 String | | | | | | |-|-|-|-|-|- -#### Day 7 Standard Traversal +#### Day 7 Linked List | | | | | | |-|-|-|-|-|- +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -#### Day 8 Standard Traversal +#### Day 8 Linked List | | | | | | |-|-|-|-|-|- +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -#### Day 9 Standard Traversal +#### Day 9 Stack Queue | | | | | | |-|-|-|-|-|- +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 -#### Day 10 Standard Traversal +#### Day 10 Tree | | | | | | |-|-|-|-|-|- +| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 -#### Day 11 Breadth First Search +#### Day 11 Tree | | | | | | |-|-|-|-|-|- +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 -#### Day 12 Breadth First Search +#### Day 12 Tree | | | | | | |-|-|-|-|-|- +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -#### Day 13 Graph Theory +#### Day 13 Tree | | | | | | |-|-|-|-|-|- -#### Day 14 Graph Theory +#### Day 14 Tree | | | | | | |-|-|-|-|-|- +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -### SQL I +### Data Structure II -#### Day 1 Select +#### Day 1 Array | | | | | | |-|-|-|-|-|- +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -#### Day 2 Select and Order +#### Day 2 Array | | | | | | |-|-|-|-|-|- +| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Day 3 String Processing Functions +#### Day 3 Array | | | | | | |-|-|-|-|-|- +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -#### Day 4 Union and Select +#### Day 4 Array | | | | | | |-|-|-|-|-|- +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 -#### Day 5 Union +#### Day 5 Array | | | | | | |-|-|-|-|-|- +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 70 | 92.45 -#### Day 6 Union +#### Day 6 String | | | | | | |-|-|-|-|-|- -#### Day 7 Function +#### Day 7 String | | | | | | |-|-|-|-|-|- +| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 54 | 94.74 -#### Day 8 Function +#### Day 8 String | | | | | | |-|-|-|-|-|- +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -#### Day 9 Control of Flow +#### Day 9 String | | | | | | |-|-|-|-|-|- +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 10 Where +#### Day 10 Linked List | | | | | | |-|-|-|-|-|- +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -### Level 1 - -#### Day 1 Prefix Sum +#### Day 11 Linked List | | | | | | |-|-|-|-|-|- +| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 -#### Day 2 String +#### Day 12 Linked List | | | | | | |-|-|-|-|-|- +| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 -#### Day 3 Linked List +#### Day 13 Linked List | | | | | | |-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 -#### Day 4 Linked List +#### Day 14 Stack Queue | | | | | | |-|-|-|-|-|- -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -#### Day 5 Greedy +#### Day 15 Tree | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 -#### Day 6 Tree +#### Day 16 Tree | | | | | | |-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -#### Day 7 Binary Search +#### Day 17 Tree | | | | | | |-|-|-|-|-|- +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 -#### Day 8 Binary Search Tree +#### Day 18 Tree | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 -#### Day 9 Graph/BFS/DFS +#### Day 19 Graph | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 10 Dynamic Programming +#### Day 20 Heap Priority Queue | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 +| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 -#### Day 11 Dynamic Programming +#### Day 21 Heap Priority Queue | | | | | | |-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -#### Day 12 Sliding Window/Two Pointer +### Algorithm I + +#### Day 1 Binary Search | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 -#### Day 13 Hashmap +#### Day 2 Two Pointers | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 -#### Day 14 Stack +#### Day 3 Two Pointers | | | | | | |-|-|-|-|-|- -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -#### Day 15 Heap +#### Day 4 Two Pointers | | | | | | |-|-|-|-|-|- -### Level 2 - -#### Day 1 Implementation/Simulation +#### Day 5 Two Pointers | | | | | | |-|-|-|-|-|- +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 -#### Day 2 String +#### Day 6 Sliding Window | | | | | | |-|-|-|-|-|- +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 -#### Day 3 Linked List +#### Day 7 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 -#### Day 4 Linked List +#### Day 8 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 -#### Day 5 Greedy +#### Day 9 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -#### Day 6 Tree +#### Day 10 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -#### Day 7 Tree +#### Day 11 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 -| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -#### Day 8 Binary Search +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -#### Day 9 Binary Search Tree +#### Day 13 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 -#### Day 10 Graph/BFS/DFS +#### Day 14 Bit Manipulation | | | | | | |-|-|-|-|-|- +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -#### Day 11 Graph/BFS/DFS +### Algorithm II + +#### Day 1 Binary Search | | | | | | |-|-|-|-|-|- +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Day 12 Dynamic Programming +#### Day 2 Binary Search | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -#### Day 13 Dynamic Programming +#### Day 3 Two Pointers | | | | | | |-|-|-|-|-|- -| 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 91 | 74.38 -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -#### Day 14 Sliding Window/Two Pointer +#### Day 4 Two Pointers | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 -| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 -#### Day 15 Tree +#### Day 5 Sliding Window | | | | | | |-|-|-|-|-|- -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 -#### Day 16 Design +#### Day 6 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 17 Interval +#### Day 7 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Day 18 Stack +#### Day 8 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -#### Day 19 Union Find +#### Day 9 Recursion Backtracking | | | | | | |-|-|-|-|-|- +| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 -#### Day 20 Brute Force/Backtracking +#### Day 10 Recursion Backtracking | | | | | | |-|-|-|-|-|- | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 - -### Udemy -#### Udemy Integers +#### Day 11 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -| 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 56 | 95.68 -| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 137 | 88.64 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 +| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 -#### Udemy Strings +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -#### Udemy Binary Search +#### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -#### Udemy Arrays +#### Day 14 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 55 | 98.51 -| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Udemy Two Pointers +#### Day 15 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -#### Udemy Famous Algorithm +#### Day 16 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Udemy Sorting Algorithms +#### Day 17 Dynamic Programming | | | | | | |-|-|-|-|-|- +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -#### Udemy 2D Arrays/Matrix +#### Day 18 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -#### Udemy Linked List +#### Day 19 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 -| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 -| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 -| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 -#### Udemy Tree Stack Queue +#### Day 20 Others | | | | | | |-|-|-|-|-|- -| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 -#### Udemy Trie and Heap +#### Day 21 Others | | | | | | |-|-|-|-|-|- -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 -#### Udemy Graph +### Binary Search I + +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Udemy Dynamic Programming +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 -#### Udemy Backtracking/Recursion +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -#### Udemy Bit Manipulation +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Top_100_Liked_Questions, Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 -#### Udemy Design +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 - -### Data Structure I +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 -#### Day 1 Array +#### Day 6 | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 -#### Day 2 Array +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 -#### Day 3 Array +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Day 4 Array +#### Day 9 | | | | | | |-|-|-|-|-|- -#### Day 5 Array +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Day 6 String +#### Day 11 | | | | | | |-|-|-|-|-|- +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -#### Day 7 Linked List +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -#### Day 8 Linked List +### Binary Search II + +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -#### Day 9 Stack Queue +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 -#### Day 10 Tree +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Day 11 Tree +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 -#### Day 12 Tree +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 -#### Day 13 Tree +#### Day 6 | | | | | | |-|-|-|-|-|- -#### Day 14 Tree +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -### Data Structure II - -#### Day 1 Array +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 -#### Day 2 Array +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Day 3 Array +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -#### Day 4 Array +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 -#### Day 5 Array +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 70 | 92.45 -#### Day 6 String +#### Day 13 | | | | | | |-|-|-|-|-|- -#### Day 7 String +#### Day 14 | | | | | | |-|-|-|-|-|- -| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 54 | 94.74 -#### Day 8 String +#### Day 15 | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -#### Day 9 String +#### Day 16 | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 10 Linked List +#### Day 17 | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -#### Day 11 Linked List +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 -#### Day 12 Linked List +#### Day 19 | | | | | | |-|-|-|-|-|- -| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 -#### Day 13 Linked List +#### Day 20 | | | | | | |-|-|-|-|-|- -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 -#### Day 14 Stack Queue +### Dynamic Programming I + +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -#### Day 15 Tree +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -#### Day 16 Tree +#### Day 3 | | | | | | |-|-|-|-|-|- +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -#### Day 17 Tree +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -#### Day 18 Tree +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 -#### Day 19 Graph +#### Day 6 | | | | | | |-|-|-|-|-|- +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -#### Day 20 Heap Priority Queue +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 -| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -#### Day 21 Heap Priority Queue +#### Day 8 | | | | | | |-|-|-|-|-|- -### Algorithm I - -#### Day 1 Binary Search +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 -#### Day 2 Two Pointers +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 -#### Day 3 Two Pointers +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 -#### Day 4 Two Pointers +#### Day 12 | | | | | | |-|-|-|-|-|- -#### Day 5 Two Pointers +#### Day 13 | | | | | | |-|-|-|-|-|- -| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 -#### Day 6 Sliding Window +#### Day 14 | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 -#### Day 7 Breadth First Search Depth First Search +#### Day 15 | | | | | | |-|-|-|-|-|- +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -#### Day 8 Breadth First Search Depth First Search +#### Day 16 | | | | | | |-|-|-|-|-|- +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 +| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 -#### Day 9 Breadth First Search Depth First Search +#### Day 17 | | | | | | |-|-|-|-|-|- +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 10 Recursion Backtracking +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Day 11 Recursion Backtracking +#### Day 19 | | | | | | |-|-|-|-|-|- -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -#### Day 12 Dynamic Programming +#### Day 20 | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -#### Day 13 Bit Manipulation +#### Day 21 | | | | | | |-|-|-|-|-|- -#### Day 14 Bit Manipulation +### Programming Skills I + +#### Day 1 Basic Data Type | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 - -### Algorithm II -#### Day 1 Binary Search +#### Day 2 Operator | | | | | | |-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -#### Day 2 Binary Search +#### Day 3 Conditional Statements | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -#### Day 3 Two Pointers +#### Day 4 Loop | | | | | | |-|-|-|-|-|- -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -#### Day 4 Two Pointers +#### Day 5 Function | | | | | | |-|-|-|-|-|- -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 -#### Day 5 Sliding Window +#### Day 6 Array | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -#### Day 6 Breadth First Search Depth First Search +#### Day 7 Array | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 7 Breadth First Search Depth First Search +#### Day 8 String | | | | | | |-|-|-|-|-|- -#### Day 8 Breadth First Search Depth First Search +#### Day 9 String | | | | | | |-|-|-|-|-|- -#### Day 9 Recursion Backtracking +#### Day 10 Linked List and Tree | | | | | | |-|-|-|-|-|- -| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -#### Day 10 Recursion Backtracking +#### Day 11 Containers and Libraries | | | | | | |-|-|-|-|-|- -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -#### Day 11 Recursion Backtracking +#### Day 12 Class and Object | | | | | | |-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 -| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 -#### Day 12 Dynamic Programming +### Programming Skills II + +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -#### Day 13 Dynamic Programming +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -#### Day 14 Dynamic Programming +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 15 Dynamic Programming +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -#### Day 16 Dynamic Programming +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Day 17 Dynamic Programming +#### Day 6 | | | | | | |-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 +| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 194 | 97.36 -#### Day 18 Dynamic Programming +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -#### Day 19 Bit Manipulation +#### Day 8 | | | | | | |-|-|-|-|-|- -#### Day 20 Others +#### Day 9 | | | | | | |-|-|-|-|-|- -#### Day 21 Others +#### Day 10 | | | | | | |-|-|-|-|-|- -### Binary Search I - -#### Day 1 +#### Day 11 | | | | | | |-|-|-|-|-|- +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -#### Day 2 +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 -#### Day 3 +#### Day 13 | | | | | | |-|-|-|-|-|- -#### Day 4 +#### Day 14 | | | | | | |-|-|-|-|-|- +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 -#### Day 5 +#### Day 15 | | | | | | |-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 -#### Day 6 +#### Day 16 | | | | | | |-|-|-|-|-|- -#### Day 7 +#### Day 17 | | | | | | |-|-|-|-|-|- -#### Day 8 +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -#### Day 9 +#### Day 19 | | | | | | |-|-|-|-|-|- -#### Day 10 +#### Day 20 | | | | | | |-|-|-|-|-|- -#### Day 11 +### Graph Theory I + +#### Day 1 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 12 +#### Day 2 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -### Binary Search II - -#### Day 1 +#### Day 3 Matrix Related Problems | | | | | | |-|-|-|-|-|- -#### Day 2 +#### Day 4 Matrix Related Problems | | | | | | |-|-|-|-|-|- -#### Day 3 +#### Day 5 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Day 4 +#### Day 6 Matrix Related Problems | | | | | | |-|-|-|-|-|- -#### Day 5 +#### Day 7 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 -#### Day 6 +#### Day 8 Standard Traversal | | | | | | |-|-|-|-|-|- -#### Day 7 +#### Day 9 Standard Traversal | | | | | | |-|-|-|-|-|- -#### Day 8 +#### Day 10 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 -#### Day 9 +#### Day 11 Breadth First Search | | | | | | |-|-|-|-|-|- -#### Day 10 +#### Day 12 Breadth First Search | | | | | | |-|-|-|-|-|- -#### Day 11 +#### Day 13 Graph Theory | | | | | | |-|-|-|-|-|- -#### Day 12 +#### Day 14 Graph Theory | | | | | | |-|-|-|-|-|- -#### Day 13 +### SQL I + +#### Day 1 Select | | | | | | |-|-|-|-|-|- -#### Day 14 +#### Day 2 Select and Order | | | | | | |-|-|-|-|-|- -#### Day 15 +#### Day 3 String Processing Functions | | | | | | |-|-|-|-|-|- -#### Day 16 +#### Day 4 Union and Select | | | | | | |-|-|-|-|-|- -#### Day 17 +#### Day 5 Union | | | | | | |-|-|-|-|-|- -#### Day 18 +#### Day 6 Union | | | | | | |-|-|-|-|-|- -#### Day 19 +#### Day 7 Function | | | | | | |-|-|-|-|-|- -#### Day 20 +#### Day 8 Function | | | | | | |-|-|-|-|-|- -### Dynamic Programming I - -#### Day 1 +#### Day 9 Control of Flow | | | | | | |-|-|-|-|-|- -#### Day 2 +#### Day 10 Where | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -#### Day 3 +### Level 1 + +#### Day 1 Prefix Sum | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -#### Day 4 +#### Day 2 String | | | | | | |-|-|-|-|-|- -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -#### Day 5 +#### Day 3 Linked List | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -#### Day 6 +#### Day 4 Linked List | | | | | | |-|-|-|-|-|- -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -#### Day 7 +#### Day 5 Greedy | | | | | | |-|-|-|-|-|- | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -#### Day 8 +#### Day 6 Tree | | | | | | |-|-|-|-|-|- +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -#### Day 9 +#### Day 7 Binary Search | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 -#### Day 10 +#### Day 8 Binary Search Tree | | | | | | |-|-|-|-|-|- +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -#### Day 11 +#### Day 9 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 12 +#### Day 10 Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -#### Day 13 +#### Day 11 Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -#### Day 14 +#### Day 12 Sliding Window/Two Pointer | | | | | | |-|-|-|-|-|- +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 -#### Day 15 +#### Day 13 Hashmap | | | | | | |-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 -#### Day 16 +#### Day 14 Stack | | | | | | |-|-|-|-|-|- -| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 -| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 -#### Day 17 +#### Day 15 Heap | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -#### Day 18 +### Level 2 + +#### Day 1 Implementation/Simulation | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -#### Day 19 +#### Day 2 String | | | | | | |-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -#### Day 20 +#### Day 3 Linked List | | | | | | |-|-|-|-|-|- -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 -#### Day 21 +#### Day 4 Linked List | | | | | | |-|-|-|-|-|- +| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 -### Programming Skills I - -#### Day 1 Basic Data Type +#### Day 5 Greedy | | | | | | |-|-|-|-|-|- -#### Day 2 Operator +#### Day 6 Tree | | | | | | |-|-|-|-|-|- +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -#### Day 3 Conditional Statements +#### Day 7 Tree | | | | | | |-|-|-|-|-|- +| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 +| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 -#### Day 4 Loop +#### Day 8 Binary Search | | | | | | |-|-|-|-|-|- +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -#### Day 5 Function +#### Day 9 Binary Search Tree | | | | | | |-|-|-|-|-|- +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 -#### Day 6 Array +#### Day 10 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -#### Day 7 Array +#### Day 11 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -#### Day 8 String +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -#### Day 9 String +#### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 91 | 74.38 +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -#### Day 10 Linked List and Tree +#### Day 14 Sliding Window/Two Pointer | | | | | | |-|-|-|-|-|- -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 +| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 -#### Day 11 Containers and Libraries +#### Day 15 Tree | | | | | | |-|-|-|-|-|- +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 -#### Day 12 Class and Object +#### Day 16 Design | | | | | | |-|-|-|-|-|- +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 -### Programming Skills II - -#### Day 1 +#### Day 17 Interval | | | | | | |-|-|-|-|-|- +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Day 2 +#### Day 18 Stack | | | | | | |-|-|-|-|-|- -#### Day 3 +#### Day 19 Union Find | | | | | | |-|-|-|-|-|- -#### Day 4 +#### Day 20 Brute Force/Backtracking | | | | | | |-|-|-|-|-|- +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -#### Day 5 +### Udemy + +#### Udemy Integers | | | | | | |-|-|-|-|-|- +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +| 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 56 | 95.68 +| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 137 | 88.64 -#### Day 6 +#### Udemy Strings | | | | | | |-|-|-|-|-|- -| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 194 | 97.36 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -#### Day 7 +#### Udemy Binary Search | | | | | | |-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -#### Day 8 +#### Udemy Arrays | | | | | | |-|-|-|-|-|- +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 +| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 55 | 98.51 +| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 -#### Day 9 +#### Udemy Two Pointers | | | | | | |-|-|-|-|-|- +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -#### Day 10 +#### Udemy Famous Algorithm | | | | | | |-|-|-|-|-|- +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 -#### Day 11 +#### Udemy Sorting Algorithms | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -#### Day 12 +#### Udemy 2D Arrays/Matrix | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 +| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -#### Day 13 +#### Udemy Linked List | | | | | | |-|-|-|-|-|- +| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 +| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 +| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 -#### Day 14 +#### Udemy Tree Stack Queue | | | | | | |-|-|-|-|-|- -| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 +| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 -#### Day 15 +#### Udemy Trie and Heap | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 -#### Day 16 +#### Udemy Graph | | | | | | |-|-|-|-|-|- +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -#### Day 17 +#### Udemy Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 -#### Day 18 +#### Udemy Backtracking/Recursion | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 +| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -#### Day 19 +#### Udemy Bit Manipulation | | | | | | |-|-|-|-|-|- +| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Top_100_Liked_Questions, Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 -#### Day 20 +#### Udemy Design | | | | | | |-|-|-|-|-|- +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 ## Algorithms From 2c1e2d98632108dcb5c74aa118b97c811313cb75 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 1 Nov 2024 05:37:38 +0200 Subject: [PATCH 09/49] Update node.yml --- .github/workflows/node.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index b2e691e..5e62cf3 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -15,7 +15,7 @@ jobs: fetch-depth: 0 - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: '20.x' From 04d9bb38f6240f505b69dfefd6193f7dd13fba1c Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 31 Jan 2025 14:10:15 +0200 Subject: [PATCH 10/49] Updated readme --- README.md | 359 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 272 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index a36c840..667e268 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) ## -* [Data Structure I](#data-structure-i) * [Data Structure II](#data-structure-ii) * [Algorithm I](#algorithm-i) * [Algorithm II](#algorithm-ii) @@ -26,92 +25,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. * [Level 1](#level-1) * [Level 2](#level-2) * [Udemy](#udemy) - -### Data Structure I - -#### Day 1 Array - -| | | | | | -|-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 - -#### Day 2 Array - -| | | | | | -|-|-|-|-|-|- -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 - -#### Day 3 Array - -| | | | | | -|-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 - -#### Day 4 Array - -| | | | | | -|-|-|-|-|-|- - -#### Day 5 Array - -| | | | | | -|-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 - -#### Day 6 String - -| | | | | | -|-|-|-|-|-|- - -#### Day 7 Linked List - -| | | | | | -|-|-|-|-|-|- -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 - -#### Day 8 Linked List - -| | | | | | -|-|-|-|-|-|- -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 - -#### Day 9 Stack Queue - -| | | | | | -|-|-|-|-|-|- -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 - -#### Day 10 Tree - -| | | | | | -|-|-|-|-|-|- -| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 - -#### Day 11 Tree - -| | | | | | -|-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 - -#### Day 12 Tree - -| | | | | | -|-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 - -#### Day 13 Tree - -| | | | | | -|-|-|-|-|-|- - -#### Day 14 Tree - -| | | | | | -|-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +* [Top Interview 150](#top-interview-150) +* [Data Structure I](#data-structure-i) ### Data Structure II @@ -1408,6 +1323,276 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +### Top Interview 150 + +#### Top Interview 150 Array/String + +| | | | | | +|-|-|-|-|-|- +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 +| 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 64 | 95.38 + +#### Top Interview 150 Two Pointers + +| | | | | | +|-|-|-|-|-|- +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 + +#### Top Interview 150 Sliding Window + +| | | | | | +|-|-|-|-|-|- +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 +| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 + +#### Top Interview 150 Matrix + +| | | | | | +|-|-|-|-|-|- +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 +| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 + +#### Top Interview 150 Hashmap + +| | | | | | +|-|-|-|-|-|- +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 92 | 93.69 + +#### Top Interview 150 Intervals + +| | | | | | +|-|-|-|-|-|- +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 + +#### Top Interview 150 Stack + +| | | | | | +|-|-|-|-|-|- +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 + +#### Top Interview 150 Linked List + +| | | | | | +|-|-|-|-|-|- +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 +| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 + +#### Top Interview 150 Binary Tree General + +| | | | | | +|-|-|-|-|-|- +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 +| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 +| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 + +#### Top Interview 150 Binary Tree BFS + +| | | | | | +|-|-|-|-|-|- +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 + +#### Top Interview 150 Binary Search Tree + +| | | | | | +|-|-|-|-|-|- +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 + +#### Top Interview 150 Graph General + +| | | | | | +|-|-|-|-|-|- +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 68 | 70.14 + +#### Top Interview 150 Graph BFS + +| | | | | | +|-|-|-|-|-|- + +#### Top Interview 150 Trie + +| | | | | | +|-|-|-|-|-|- +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 + +#### Top Interview 150 Backtracking + +| | | | | | +|-|-|-|-|-|- +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 +| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 + +#### Top Interview 150 Divide and Conquer + +| | | | | | +|-|-|-|-|-|- +| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 +| 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 76 | 94.52 + +#### Top Interview 150 Kadane's Algorithm + +| | | | | | +|-|-|-|-|-|- +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 + +#### Top Interview 150 Binary Search + +| | | | | | +|-|-|-|-|-|- +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +| 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Big_O_Time_O(log(min(N,M)))_Space_O(1) | 86 | 92.15 + +#### Top Interview 150 Heap + +| | | | | | +|-|-|-|-|-|- +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 +| 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 335 | 99.44 + +#### Top Interview 150 Bit Manipulation + +| | | | | | +|-|-|-|-|-|- +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 + +#### Top Interview 150 Math + +| | | | | | +|-|-|-|-|-|- +| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 137 | 88.64 + +#### Top Interview 150 1D DP + +| | | | | | +|-|-|-|-|-|- +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 + +#### Top Interview 150 Multidimensional DP + +| | | | | | +|-|-|-|-|-|- +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 + +### Data Structure I + +#### Day 1 Array + +| | | | | | +|-|-|-|-|-|- +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 + +#### Day 2 Array + +| | | | | | +|-|-|-|-|-|- +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 + +#### Day 3 Array + +| | | | | | +|-|-|-|-|-|- +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 + +#### Day 4 Array + +| | | | | | +|-|-|-|-|-|- + +#### Day 5 Array + +| | | | | | +|-|-|-|-|-|- +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 + +#### Day 6 String + +| | | | | | +|-|-|-|-|-|- + +#### Day 7 Linked List + +| | | | | | +|-|-|-|-|-|- +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 + +#### Day 8 Linked List + +| | | | | | +|-|-|-|-|-|- +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 + +#### Day 9 Stack Queue + +| | | | | | +|-|-|-|-|-|- +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 + +#### Day 10 Tree + +| | | | | | +|-|-|-|-|-|- +| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 + +#### Day 11 Tree + +| | | | | | +|-|-|-|-|-|- +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 + +#### Day 12 Tree + +| | | | | | +|-|-|-|-|-|- +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 + +#### Day 13 Tree + +| | | | | | +|-|-|-|-|-|- + +#### Day 14 Tree + +| | | | | | +|-|-|-|-|-|- +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 + ## Algorithms | # | Title | Difficulty | Tag | Time, ms | Time, % From 4492d3c41ff88888e2f8498c82f5515fd00d14da Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sat, 15 Feb 2025 17:47:18 +0200 Subject: [PATCH 11/49] Improved tags --- README.md | 528 +++++++++--------- .../ts/g0001_0100/s0001_two_sum/solution.ts | 3 +- .../s0002_add_two_numbers/solution.ts | 3 +- .../solution.ts | 3 +- .../solution.ts | 3 +- .../solution.ts | 4 +- .../s0006_zigzag_conversion/solution.ts | 3 +- .../s0009_palindrome_number/solution.ts | 3 +- .../solution.ts | 5 +- .../solution.ts | 2 +- src/main/ts/g0001_0100/s0015_3sum/solution.ts | 3 +- .../solution.ts | 3 +- .../solution.ts | 4 +- .../s0020_valid_parentheses/solution.ts | 4 +- .../s0021_merge_two_sorted_lists/solution.ts | 4 +- .../s0022_generate_parentheses/solution.ts | 3 +- .../s0023_merge_k_sorted_lists/solution.ts | 4 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 4 +- .../s0035_search_insert_position/solution.ts | 2 +- .../s0039_combination_sum/solution.ts | 3 +- .../s0042_trapping_rain_water/solution.ts | 3 +- .../g0001_0100/s0045_jump_game_ii/solution.ts | 3 +- .../g0001_0100/s0046_permutations/solution.ts | 2 +- .../g0001_0100/s0048_rotate_image/solution.ts | 3 +- .../s0049_group_anagrams/solution.ts | 3 +- .../s0053_maximum_subarray/solution.ts | 4 +- .../ts/g0001_0100/s0055_jump_game/solution.ts | 3 +- .../s0056_merge_intervals/solution.ts | 3 +- .../s0064_minimum_path_sum/solution.ts | 4 +- .../s0070_climbing_stairs/solution.ts | 4 +- .../g0001_0100/s0072_edit_distance/readme.md | 2 +- .../s0072_edit_distance/solution.ts | 6 +- .../s0073_set_matrix_zeroes/solution.ts | 2 +- .../s0074_search_a_2d_matrix/solution.ts | 2 +- .../solution.ts | 4 +- .../g0001_0100/s0079_word_search/solution.ts | 4 +- .../solution.ts | 4 +- .../solution.ts | 2 +- .../s0101_symmetric_tree/solution.ts | 3 +- .../solution.ts | 3 +- .../solution.ts | 3 +- .../solution.ts | 4 +- .../solution.ts | 2 +- .../solution.ts | 3 +- .../solution.ts | 4 +- .../solution.ts | 3 +- .../s0136_single_number/solution.ts | 3 +- .../solution.ts | 4 +- .../g0101_0200/s0139_word_break/solution.ts | 4 +- .../s0141_linked_list_cycle/solution.ts | 4 +- .../ts/g0101_0200/s0146_lru_cache/solution.ts | 4 +- .../ts/g0101_0200/s0148_sort_list/solution.ts | 4 +- .../solution.ts | 4 +- .../ts/g0101_0200/s0155_min_stack/solution.ts | 5 +- .../s0169_majority_element/solution.ts | 3 +- .../g0101_0200/s0189_rotate_array/solution.ts | 4 +- .../g0101_0200/s0198_house_robber/solution.ts | 4 +- .../s0200_number_of_islands/solution.ts | 3 +- .../s0207_course_schedule/solution.ts | 4 +- .../solution.ts | 2 +- .../solution.ts | 3 +- .../s0221_maximal_square/solution.ts | 4 +- .../s0226_invert_binary_tree/solution.ts | 3 +- .../solution.ts | 7 +- .../s0234_palindrome_linked_list/solution.ts | 4 +- .../solution.ts | 6 +- .../solution.ts | 4 +- .../s0239_sliding_window_maximum/solution.ts | 4 +- .../s0240_search_a_2d_matrix_ii/solution.ts | 6 +- .../g0201_0300/s0283_move_zeroes/solution.ts | 6 +- .../solution.ts | 4 +- .../solution.ts | 4 +- .../solution.ts | 6 +- .../g0301_0400/s0322_coin_change/solution.ts | 6 +- .../s0338_counting_bits/solution.ts | 2 +- .../s0347_top_k_frequent_elements/solution.ts | 7 +- .../g0401_0500/s0437_path_sum_iii/solution.ts | 4 +- .../g0401_0500/s0494_target_sum/solution.ts | 3 +- .../s0647_palindromic_substrings/solution.ts | 2 +- .../s0763_partition_labels/solution.ts | 5 +- 82 files changed, 422 insertions(+), 398 deletions(-) diff --git a/README.md b/README.md index 667e268..1abeed6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) ## -* [Data Structure II](#data-structure-ii) * [Algorithm I](#algorithm-i) * [Algorithm II](#algorithm-ii) * [Binary Search I](#binary-search-i) @@ -27,136 +26,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. * [Udemy](#udemy) * [Top Interview 150](#top-interview-150) * [Data Structure I](#data-structure-i) - -### Data Structure II - -#### Day 1 Array - -| | | | | | -|-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 - -#### Day 2 Array - -| | | | | | -|-|-|-|-|-|- -| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 - -#### Day 3 Array - -| | | | | | -|-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 - -#### Day 4 Array - -| | | | | | -|-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 - -#### Day 5 Array - -| | | | | | -|-|-|-|-|-|- -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 70 | 92.45 - -#### Day 6 String - -| | | | | | -|-|-|-|-|-|- - -#### Day 7 String - -| | | | | | -|-|-|-|-|-|- -| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 54 | 94.74 - -#### Day 8 String - -| | | | | | -|-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 - -#### Day 9 String - -| | | | | | -|-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 - -#### Day 10 Linked List - -| | | | | | -|-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 - -#### Day 11 Linked List - -| | | | | | -|-|-|-|-|-|- -| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 - -#### Day 12 Linked List - -| | | | | | -|-|-|-|-|-|- -| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 - -#### Day 13 Linked List - -| | | | | | -|-|-|-|-|-|- -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 - -#### Day 14 Stack Queue - -| | | | | | -|-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 - -#### Day 15 Tree - -| | | | | | -|-|-|-|-|-|- -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 - -#### Day 16 Tree - -| | | | | | -|-|-|-|-|-|- - -#### Day 17 Tree - -| | | | | | -|-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 - -#### Day 18 Tree - -| | | | | | -|-|-|-|-|-|- -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 - -#### Day 19 Graph - -| | | | | | -|-|-|-|-|-|- - -#### Day 20 Heap Priority Queue - -| | | | | | -|-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 -| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 - -#### Day 21 Heap Priority Queue - -| | | | | | -|-|-|-|-|-|- +* [Data Structure II](#data-structure-ii) ### Algorithm I @@ -176,7 +46,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 #### Day 4 Two Pointers @@ -193,7 +63,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 #### Day 7 Breadth First Search Depth First Search @@ -340,7 +210,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 #### Day 17 Dynamic Programming @@ -352,8 +222,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 #### Day 19 Bit Manipulation @@ -453,7 +323,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 #### Day 4 @@ -464,7 +334,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 +| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 #### Day 6 @@ -480,7 +350,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 #### Day 9 @@ -572,7 +442,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 #### Day 6 @@ -607,7 +477,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 +| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 #### Day 12 @@ -635,7 +505,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 -| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 +| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 #### Day 17 @@ -647,20 +517,20 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 #### Day 19 | | | | | | |-|-|-|-|-|- | 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 #### Day 20 | | | | | | |-|-|-|-|-|- -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 #### Day 21 @@ -698,7 +568,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 #### Day 7 Array @@ -812,7 +682,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 92 | 77.86 #### Day 16 @@ -828,7 +698,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 #### Day 19 @@ -1041,7 +911,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 #### Day 14 Stack @@ -1071,7 +941,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 #### Day 4 Linked List @@ -1095,7 +965,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 -| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 +| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 #### Day 8 Binary Search @@ -1108,7 +978,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 #### Day 10 Graph/BFS/DFS @@ -1125,7 +995,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 #### Day 13 Dynamic Programming @@ -1138,7 +1008,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 | 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 #### Day 15 Tree @@ -1151,7 +1021,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 | 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 #### Day 17 Interval @@ -1191,7 +1061,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 | 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 @@ -1209,14 +1079,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 | 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 55 | 98.51 -| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 +| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 #### Udemy Two Pointers @@ -1229,7 +1099,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 #### Udemy Sorting Algorithms @@ -1257,7 +1127,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 | 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 | 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 | 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 | 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 @@ -1273,7 +1143,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 #### Udemy Trie and Heap @@ -1296,10 +1166,10 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 | 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 #### Udemy Backtracking/Recursion @@ -1315,13 +1185,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Top_100_Liked_Questions, Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 +| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 #### Udemy Design | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 ### Top Interview 150 @@ -1334,7 +1204,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 | 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 64 | 95.38 @@ -1349,7 +1219,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 | 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 #### Top Interview 150 Matrix @@ -1364,7 +1234,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 | 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 92 | 93.69 #### Top Interview 150 Intervals @@ -1378,14 +1248,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 #### Top Interview 150 Linked List | | | | | | |-|-|-|-|-|- | 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 92 | 77.86 | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 | 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 | 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 @@ -1402,7 +1272,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 #### Top Interview 150 Binary Tree BFS @@ -1414,7 +1284,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 #### Top Interview 150 Graph General @@ -1456,7 +1326,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 #### Top Interview 150 Binary Search @@ -1467,14 +1337,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 | 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -| 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Big_O_Time_O(log(min(N,M)))_Space_O(1) | 86 | 92.15 +| 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Big_O_Time_O(log(min(N,M)))_Space_O(1), AI_can_be_used_to_solve_the_task | 86 | 92.15 #### Top Interview 150 Heap | | | | | | |-|-|-|-|-|- | 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 -| 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 335 | 99.44 +| 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 335 | 99.44 #### Top Interview 150 Bit Manipulation @@ -1495,8 +1365,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 #### Top Interview 150 Multidimensional DP @@ -1504,8 +1374,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 ### Data Structure I @@ -1513,13 +1383,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 #### Day 2 Array | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 #### Day 3 Array @@ -1593,114 +1463,244 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +### Data Structure II + +#### Day 1 Array + +| | | | | | +|-|-|-|-|-|- +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 + +#### Day 2 Array + +| | | | | | +|-|-|-|-|-|- +| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 + +#### Day 3 Array + +| | | | | | +|-|-|-|-|-|- +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 + +#### Day 4 Array + +| | | | | | +|-|-|-|-|-|- +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 + +#### Day 5 Array + +| | | | | | +|-|-|-|-|-|- +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 70 | 92.45 + +#### Day 6 String + +| | | | | | +|-|-|-|-|-|- + +#### Day 7 String + +| | | | | | +|-|-|-|-|-|- +| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 3 | 97.96 + +#### Day 8 String + +| | | | | | +|-|-|-|-|-|- +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 + +#### Day 9 String + +| | | | | | +|-|-|-|-|-|- +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 + +#### Day 10 Linked List + +| | | | | | +|-|-|-|-|-|- +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 92 | 77.86 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 + +#### Day 11 Linked List + +| | | | | | +|-|-|-|-|-|- +| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 + +#### Day 12 Linked List + +| | | | | | +|-|-|-|-|-|- +| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 + +#### Day 13 Linked List + +| | | | | | +|-|-|-|-|-|- +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 + +#### Day 14 Stack Queue + +| | | | | | +|-|-|-|-|-|- +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 + +#### Day 15 Tree + +| | | | | | +|-|-|-|-|-|- +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 + +#### Day 16 Tree + +| | | | | | +|-|-|-|-|-|- + +#### Day 17 Tree + +| | | | | | +|-|-|-|-|-|- +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 + +#### Day 18 Tree + +| | | | | | +|-|-|-|-|-|- +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 + +#### Day 19 Graph + +| | | | | | +|-|-|-|-|-|- + +#### Day 20 Heap Priority Queue + +| | | | | | +|-|-|-|-|-|- +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 +| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 + +#### Day 21 Heap Priority Queue + +| | | | | | +|-|-|-|-|-|- + ## Algorithms | # | Title | Difficulty | Tag | Time, ms | Time, % |------|----------------|-------------|-------------|----------|--------- | 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_17_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers, Data_Structure_II_Day_7_String, Big_O_Time_O(n)_Space_O(1) | 54 | 94.74 +| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | String, Hash_Table, Greedy, Two_Pointers, Data_Structure_II_Day_7_String, Big_O_Time_O(n)_Space_O(1) | 3 | 97.96 | 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Programming_Skills_II_Day_6, Big_O_Time_O(n)_Space_O(n) | 194 | 97.36 -| 0647 |[Palindromic Substrings](src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n) | 60 | 89.76 +| 0647 |[Palindromic Substrings](src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts)| Medium | String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n) | 60 | 89.76 | 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Data_Structure_II_Day_5_Array, Big_O_Time_O(n)_Space_O(n) | 70 | 92.45 | 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 -| 0494 |[Target Sum](src/main/ts/g0401_0500/s0494_target_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Backtracking, Big_O_Time_O(n\*(sum+s))_Space_O(n\*(sum+s)) | 77 | 81.99 +| 0494 |[Target Sum](src/main/ts/g0401_0500/s0494_target_sum/solution.ts)| Medium | Array, Dynamic_Programming, Backtracking, Big_O_Time_O(n\*(sum+s))_Space_O(n\*(sum+s)) | 77 | 81.99 | 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Programming_Skills_II_Day_12, Level_1_Day_12_Sliding_Window/Two_Pointer, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 -| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 +| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 | 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Level_2_Day_13_Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 91 | 74.38 | 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Level_1_Day_14_Stack, Udemy_Strings, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 -| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Data_Structure_II_Day_20_Heap_Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 -| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Top_100_Liked_Questions, Dynamic_Programming, Bit_Manipulation, Udemy_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_20, Level_2_Day_12_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search, Algorithm_II_Day_16_Dynamic_Programming, Binary_Search_II_Day_3, Dynamic_Programming_I_Day_18, Udemy_Dynamic_Programming, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -| 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 335 | 99.44 -| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Binary_Search_II_Day_5, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Programming_Skills_I_Day_6_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Data_Structure_II_Day_4_Array, Binary_Search_II_Day_8, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 -| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Udemy_Arrays, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum, Data_Structure_II_Day_5_Array, Udemy_Arrays, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_18_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion, Level_2_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_II_Day_17_Tree, Level_2_Day_9_Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Level_2_Day_6_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Data_Structure_II_Day_20_Heap_Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Level_2_Day_16_Design, Udemy_Trie_and_Heap, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 -| 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 68 | 70.14 +| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Data_Structure_II_Day_20_Heap_Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 +| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Udemy_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_20, Level_2_Day_12_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Algorithm_II_Day_16_Dynamic_Programming, Binary_Search_II_Day_3, Dynamic_Programming_I_Day_18, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Top_Interview_150_Heap, Big_O_Time_O(n\*log_n)_Space_O(n) | 335 | 99.44 +| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Binary_Search_II_Day_5, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Programming_Skills_I_Day_6_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Data_Structure_II_Day_4_Array, Binary_Search_II_Day_8, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 +| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Udemy_Arrays, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Data_Structure_II_Day_5_Array, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_18_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Level_2_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_II_Day_17_Tree, Level_2_Day_9_Binary_Search_Tree, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Level_2_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Data_Structure_II_Day_20_Heap_Priority_Queue, Top_Interview_150_Heap, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Level_2_Day_16_Design, Udemy_Trie_and_Heap, Top_Interview_150_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 +| 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Top_Interview_150_Graph_General, Big_O_Time_O(N)_Space_O(N) | 68 | 70.14 | 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_8_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search, Graph_Theory_I_Day_1_Matrix_Related_Problems, Level_1_Day_9_Graph/BFS/DFS, Udemy_Graph, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_3, Level_2_Day_12_Dynamic_Programming, Udemy_Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Algorithm_I_Day_2_Two_Pointers, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Data_Structure_II_Day_1_Array, Udemy_Famous_Algorithm, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search, Graph_Theory_I_Day_1_Matrix_Related_Problems, Level_1_Day_9_Graph/BFS/DFS, Udemy_Graph, Top_Interview_150_Graph_General, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_3, Level_2_Day_12_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Algorithm_I_Day_2_Two_Pointers, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Data_Structure_II_Day_1_Array, Udemy_Famous_Algorithm, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 | 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_II_Day_11_Linked_List, Udemy_Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Data_Structure_II_Day_14_Stack_Queue, Programming_Skills_II_Day_18, Level_2_Day_16_Design, Udemy_Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_I_Day_12, Udemy_Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Data_Structure_II_Day_14_Stack_Queue, Programming_Skills_II_Day_18, Level_2_Day_16_Design, Udemy_Design, Top_Interview_150_Stack, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_I_Day_12, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 | 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Dynamic_Programming_I_Day_6, Level_2_Day_13_Dynamic_Programming, Udemy_Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Level_2_Day_4_Linked_List, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 -| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Udemy_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 +| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Level_2_Day_4_Linked_List, Top_Interview_150_Divide_and_Conquer, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 +| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 | 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_II_Day_10_Linked_List, Level_1_Day_4_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_I_Day_7_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Algorithm_II_Day_15_Dynamic_Programming, Dynamic_Programming_I_Day_9, Udemy_Dynamic_Programming, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Programming_Skills_II_Day_14, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Data_Structure_II_Day_1_Array, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Integers, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_I_Day_7_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Algorithm_II_Day_15_Dynamic_Programming, Dynamic_Programming_I_Day_9, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Programming_Skills_II_Day_14, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Data_Structure_II_Day_1_Array, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Integers, Top_Interview_150_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 | 0131 |[Palindrome Partitioning](src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(N\*2^N)_Space_O(2^N\*N) | 203 | 99.22 -| 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 92 | 93.69 -| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Data_Structure_I_Day_3_Array, Dynamic_Programming_I_Day_7, Level_1_Day_5_Greedy, Udemy_Arrays, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Programming_Skills_I_Day_10_Linked_List_and_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_1_Day_6_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_2_Day_15_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_I_Day_14_Tree, Level_1_Day_8_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Dynamic_Programming_I_Day_11, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 +| 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Top_Interview_150_Hashmap, Big_O_Time_O(N_log_N)_Space_O(1) | 92 | 93.69 +| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Data_Structure_I_Day_3_Array, Dynamic_Programming_I_Day_7, Level_1_Day_5_Greedy, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Udemy_Linked_List, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Programming_Skills_I_Day_10_Linked_List_and_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_1_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_I_Day_14_Tree, Level_1_Day_8_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Dynamic_Programming_I_Day_11, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 | 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Data_Structure_I_Day_10_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 | 0084 |[Largest Rectangle in Histogram](src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n_log_n)_Space_O(log_n) | 78 | 92.44 -| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 +| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Top_Interview_150_Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 | 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Algorithm_II_Day_9_Recursion_Backtracking, Udemy_Backtracking/Recursion, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 -| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 +| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Top_Interview_150_Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_2_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Data_Structure_I_Day_5_Array, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_8, Level_2_Day_8_Binary_Search, Udemy_2D_Arrays/Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Udemy_2D_Arrays/Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_2, Level_1_Day_10_Dynamic_Programming, Udemy_Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Udemy_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Data_Structure_I_Day_5_Array, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_8, Level_2_Day_8_Binary_Search, Udemy_2D_Arrays/Matrix, Top_Interview_150_Binary_Search, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_2, Level_1_Day_10_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 | 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_15, Level_1_Day_11_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Data_Structure_II_Day_2_Array, Level_2_Day_17_Interval, Udemy_2D_Arrays/Matrix, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_4, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Data_Structure_I_Day_1_Array, Dynamic_Programming_I_Day_5, Udemy_Famous_Algorithm, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Data_Structure_II_Day_2_Array, Level_2_Day_17_Interval, Udemy_2D_Arrays/Matrix, Top_Interview_150_Intervals, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_4, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Data_Structure_I_Day_1_Array, Dynamic_Programming_I_Day_5, Udemy_Famous_Algorithm, Top_Interview_150_Kadane's_Algorithm, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 | 0051 |[N-Queens](src/main/ts/g0001_0100/s0051_n_queens/solution.ts)| Hard | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(N!)_Space_O(N) | 57 | 93.84 -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Data_Structure_II_Day_8_String, Programming_Skills_II_Day_11, Udemy_Strings, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Data_Structure_II_Day_3_Array, Programming_Skills_II_Day_7, Udemy_2D_Arrays/Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Algorithm_I_Day_11_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_4, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Dynamic_Programming_I_Day_9, Udemy_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Data_Structure_II_Day_8_String, Programming_Skills_II_Day_11, Udemy_Strings, Top_Interview_150_Hashmap, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Data_Structure_II_Day_3_Array, Programming_Skills_II_Day_7, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Algorithm_I_Day_11_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_4, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Dynamic_Programming_I_Day_9, Udemy_Two_Pointers, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 | 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Udemy_Arrays, Big_O_Time_O(n)_Space_O(n) | 55 | 98.51 -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Algorithm_II_Day_10_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_I_Day_1_Binary_Search, Binary_Search_I_Day_2, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_5, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_11, Level_2_Day_8_Binary_Search, Udemy_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Algorithm_II_Day_10_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_I_Day_1_Binary_Search, Binary_Search_I_Day_2, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_5, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_11, Level_2_Day_8_Binary_Search, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 | 0032 |[Longest Valid Parentheses](src/main/ts/g0001_0100/s0032_longest_valid_parentheses/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Stack, Big_O_Time_O(n)_Space_O(1) | 56 | 89.31 | 0031 |[Next Permutation](src/main/ts/g0001_0100/s0031_next_permutation/solution.ts)| Medium | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 47 | 99.30 -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_13_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_13_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 | 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_12_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 -| 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 76 | 94.52 -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_7_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Data_Structure_I_Day_9_Stack_Queue, Udemy_Strings, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 -| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Algorithm_I_Day_5_Two_Pointers, Level_2_Day_3_Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_1_Array, Algorithm_II_Day_3_Two_Pointers, Udemy_Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Algorithm_II_Day_4_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 -| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Recursion, Udemy_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 -| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math, Udemy_Integers | 137 | 88.64 +| 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Top_Interview_150_Divide_and_Conquer, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 76 | 94.52 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_7_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Data_Structure_I_Day_9_Stack_Queue, Udemy_Strings, Top_Interview_150_Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Algorithm_I_Day_5_Two_Pointers, Level_2_Day_3_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_1_Array, Algorithm_II_Day_3_Two_Pointers, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Algorithm_II_Day_4_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 +| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Udemy_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 +| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math, Udemy_Integers, Top_Interview_150_Math | 137 | 88.64 | 0008 |[String to Integer (atoi)](src/main/ts/g0001_0100/s0008_string_to_integer_atoi/solution.ts)| Medium | Top_Interview_Questions, String | 56 | 99.01 | 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math, Udemy_Integers | 56 | 95.68 -| 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 64 | 95.38 -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Data_Structure_II_Day_9_String, Algorithm_II_Day_14_Dynamic_Programming, Dynamic_Programming_I_Day_17, Udemy_Strings, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -| 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Big_O_Time_O(log(min(N,M)))_Space_O(1) | 86 | 92.15 -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Algorithm_I_Day_6_Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Udemy_Strings, Big_O_Time_O(n)_Space_O(1) | 65 | 90.77 -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Data_Structure_II_Day_10_Linked_List, Programming_Skills_II_Day_15, Big_O_Time_O(max(N,M))_Space_O(max(N,M)) | 92 | 77.86 -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Data_Structure_I_Day_2_Array, Level_1_Day_13_Hashmap, Udemy_Arrays, Big_O_Time_O(n)_Space_O(n) | 54 | 91.72 +| 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String, Top_Interview_150_Array/String | 64 | 95.38 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Data_Structure_II_Day_9_String, Algorithm_II_Day_14_Dynamic_Programming, Dynamic_Programming_I_Day_17, Udemy_Strings, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 +| 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Top_Interview_150_Binary_Search, Big_O_Time_O(log(min(N,M)))_Space_O(1), AI_can_be_used_to_solve_the_task | 86 | 92.15 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Algorithm_I_Day_6_Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Udemy_Strings, Top_Interview_150_Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Data_Structure_II_Day_10_Linked_List, Programming_Skills_II_Day_15, Top_Interview_150_Linked_List, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 92 | 77.86 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Data_Structure_I_Day_2_Array, Level_1_Day_13_Hashmap, Udemy_Arrays, Top_Interview_150_Hashmap, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 ## Contributing Your ideas/fixes/algorithms are more than welcome! diff --git a/src/main/ts/g0001_0100/s0001_two_sum/solution.ts b/src/main/ts/g0001_0100/s0001_two_sum/solution.ts index 53bdeaf..e2a22d1 100644 --- a/src/main/ts/g0001_0100/s0001_two_sum/solution.ts +++ b/src/main/ts/g0001_0100/s0001_two_sum/solution.ts @@ -1,5 +1,6 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table -// #Data_Structure_I_Day_2_Array #Level_1_Day_13_Hashmap #Udemy_Arrays #Big_O_Time_O(n)_Space_O(n) +// #Data_Structure_I_Day_2_Array #Level_1_Day_13_Hashmap #Udemy_Arrays #Top_Interview_150_Hashmap +// #Big_O_Time_O(n)_Space_O(n) #AI_can_be_used_to_solve_the_task // #2023_09_28_Time_54_ms_(91.72%)_Space_45.5_MB_(22.26%) function twoSum(nums: number[], target: number): number[] { diff --git a/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts b/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts index 3672386..d07c69d 100644 --- a/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts +++ b/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Math #Linked_List #Recursion // #Data_Structure_II_Day_10_Linked_List #Programming_Skills_II_Day_15 -// #Big_O_Time_O(max(N,M))_Space_O(max(N,M)) #2023_09_28_Time_92_ms_(77.86%)_Space_48_MB_(69.29%) +// #Top_Interview_150_Linked_List #Big_O_Time_O(max(N,M))_Space_O(max(N,M)) +// #AI_can_be_used_to_solve_the_task #2023_09_28_Time_92_ms_(77.86%)_Space_48_MB_(69.29%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts b/src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts index 595d1d0..8e5d2ec 100644 --- a/src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts +++ b/src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Sliding_Window // #Algorithm_I_Day_6_Sliding_Window #Level_2_Day_14_Sliding_Window/Two_Pointer #Udemy_Strings -// #Big_O_Time_O(n)_Space_O(1) #2023_09_28_Time_65_ms_(90.77%)_Space_44.9_MB_(95.29%) +// #Top_Interview_150_Sliding_Window #Big_O_Time_O(n)_Space_O(1) #AI_can_be_used_to_solve_the_task +// #2023_09_28_Time_65_ms_(90.77%)_Space_44.9_MB_(95.29%) function lengthOfLongestSubstring(s: string): number { const lastIndices: number[] = new Array(256).fill(-1) diff --git a/src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts b/src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts index fdbf3eb..dfc3200 100644 --- a/src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts +++ b/src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts @@ -1,5 +1,6 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search #Divide_and_Conquer -// #Big_O_Time_O(log(min(N,M)))_Space_O(1) #2023_08_26_Time_86_ms_(92.15%)_Space_48.3_MB_(59.73%) +// #Top_Interview_150_Binary_Search #Big_O_Time_O(log(min(N,M)))_Space_O(1) +// #AI_can_be_used_to_solve_the_task #2023_08_26_Time_86_ms_(92.15%)_Space_48.3_MB_(59.73%) function findMedianSortedArrays(nums1: number[], nums2: number[]): number { const nums = nums1.concat(nums2) diff --git a/src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts b/src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts index c76fac1..a4f3964 100644 --- a/src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts +++ b/src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming // #Data_Structure_II_Day_9_String #Algorithm_II_Day_14_Dynamic_Programming -// #Dynamic_Programming_I_Day_17 #Udemy_Strings #Big_O_Time_O(n)_Space_O(n) -// #2023_09_28_Time_68_ms_(95.34%)_Space_44.5_MB_(96.58%) +// #Dynamic_Programming_I_Day_17 #Udemy_Strings #Top_Interview_150_Multidimensional_DP +// #Big_O_Time_O(n)_Space_O(n) #2023_09_28_Time_68_ms_(95.34%)_Space_44.5_MB_(96.58%) function longestPalindrome(s: string): string { const newStr: string[] = new Array(s.length * 2 + 1) diff --git a/src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts b/src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts index a1aab88..f34e6ed 100644 --- a/src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts +++ b/src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts @@ -1,4 +1,5 @@ -// #Medium #String #2023_08_26_Time_64_ms_(95.38%)_Space_47.3_MB_(64.49%) +// #Medium #String #Top_Interview_150_Array/String +// #2023_08_26_Time_64_ms_(95.38%)_Space_47.3_MB_(64.49%) function convert(s: string, numRows: number): string { if (numRows < 2) { diff --git a/src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts b/src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts index 117a804..2bab920 100644 --- a/src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts +++ b/src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts @@ -1,4 +1,5 @@ -// #Easy #Math #Udemy_Integers #2023_08_25_Time_137_ms_(88.64%)_Space_50.5_MB_(99.43%) +// #Easy #Math #Udemy_Integers #Top_Interview_150_Math +// #2023_08_25_Time_137_ms_(88.64%)_Space_50.5_MB_(99.43%) function isPalindrome(x: number): boolean { if (x < 0) { diff --git a/src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts b/src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts index fed1d99..a98eff9 100644 --- a/src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts +++ b/src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts @@ -1,6 +1,5 @@ -// #Hard #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming #Recursion -// #Udemy_Dynamic_Programming #Big_O_Time_O(m*n)_Space_O(m*n) -// #2023_08_25_Time_69_ms_(92.65%)_Space_45.9_MB_(50.61%) +// #Hard #Top_Interview_Questions #String #Dynamic_Programming #Recursion #Udemy_Dynamic_Programming +// #Big_O_Time_O(m*n)_Space_O(m*n) #2023_08_25_Time_69_ms_(92.65%)_Space_45.9_MB_(50.61%) function isMatch(s: string, p: string): boolean { // NOSONAR const result = new Array(s.length + 1) diff --git a/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts b/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts index f4c6efb..684d7be 100644 --- a/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts +++ b/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Greedy #Two_Pointers -// #Algorithm_II_Day_4_Two_Pointers #Big_O_Time_O(n)_Space_O(1) +// #Algorithm_II_Day_4_Two_Pointers #Top_Interview_150_Two_Pointers #Big_O_Time_O(n)_Space_O(1) // #2023_08_28_Time_57_ms_(98.23%)_Space_50.9_MB_(84.15%) function maxArea(height: number[]): number { diff --git a/src/main/ts/g0001_0100/s0015_3sum/solution.ts b/src/main/ts/g0001_0100/s0015_3sum/solution.ts index 67fdc8b..da7842f 100644 --- a/src/main/ts/g0001_0100/s0015_3sum/solution.ts +++ b/src/main/ts/g0001_0100/s0015_3sum/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting #Two_Pointers // #Data_Structure_II_Day_1_Array #Algorithm_II_Day_3_Two_Pointers #Udemy_Two_Pointers -// #Big_O_Time_O(n*log(n))_Space_O(n^2) #2023_08_28_Time_148_ms_(92.62%)_Space_59.1_MB_(70.24%) +// #Top_Interview_150_Two_Pointers #Big_O_Time_O(n*log(n))_Space_O(n^2) +// #2023_08_28_Time_148_ms_(92.62%)_Space_59.1_MB_(70.24%) function threeSum(nums: number[]): number[][] { //NOSONAR nums.sort((a, b) => a - b) diff --git a/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts b/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts index fea016e..9e0425e 100644 --- a/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts +++ b/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Backtracking // #Algorithm_II_Day_11_Recursion_Backtracking #Udemy_Backtracking/Recursion -// #Big_O_Time_O(4^n)_Space_O(n) #2023_08_28_Time_52_ms_(79.11%)_Space_43.7_MB_(37.41%) +// #Top_Interview_150_Backtracking #Big_O_Time_O(4^n)_Space_O(n) +// #2023_08_28_Time_52_ms_(79.11%)_Space_43.7_MB_(37.41%) function letterCombinations(digits: string): string[] { if (digits.length === 0) { diff --git a/src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts b/src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts index b470822..c33ee8e 100644 --- a/src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts +++ b/src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Two_Pointers #Linked_List -// #Algorithm_I_Day_5_Two_Pointers #Level_2_Day_3_Linked_List #Big_O_Time_O(L)_Space_O(L) -// #2023_08_28_Time_54_ms_(87.87%)_Space_44.7_MB_(49.30%) +// #Algorithm_I_Day_5_Two_Pointers #Level_2_Day_3_Linked_List #Top_Interview_150_Linked_List +// #Big_O_Time_O(L)_Space_O(L) #2023_08_28_Time_54_ms_(87.87%)_Space_44.7_MB_(49.30%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts b/src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts index 4f06406..9095bef 100644 --- a/src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts +++ b/src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #String #Stack -// #Data_Structure_I_Day_9_Stack_Queue #Udemy_Strings #Big_O_Time_O(n)_Space_O(n) -// #2023_08_28_Time_50_ms_(95.90%)_Space_43.5_MB_(83.27%) +// #Data_Structure_I_Day_9_Stack_Queue #Udemy_Strings #Top_Interview_150_Stack +// #Big_O_Time_O(n)_Space_O(n) #2023_08_28_Time_50_ms_(95.90%)_Space_43.5_MB_(83.27%) function isValid(s: string): boolean { const stack: string[] = [] diff --git a/src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts b/src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts index 284ba47..7507f19 100644 --- a/src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts +++ b/src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Linked_List #Recursion // #Data_Structure_I_Day_7_Linked_List #Algorithm_I_Day_10_Recursion_Backtracking -// #Level_1_Day_3_Linked_List #Udemy_Linked_List #Big_O_Time_O(m+n)_Space_O(m+n) -// #2023_08_29_Time_59_ms_(86.77%)_Space_44_MB_(98.03%) +// #Level_1_Day_3_Linked_List #Udemy_Linked_List #Top_Interview_150_Linked_List +// #Big_O_Time_O(m+n)_Space_O(m+n) #2023_08_29_Time_59_ms_(86.77%)_Space_44_MB_(98.03%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts b/src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts index 9db8687..1e8dfe9 100644 --- a/src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts +++ b/src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming // #Backtracking #Algorithm_II_Day_11_Recursion_Backtracking #Udemy_Backtracking/Recursion -// #Big_O_Time_O(2^n)_Space_O(n) #2023_08_29_Time_60_ms_(62.03%)_Space_45.6_MB_(21.59%) +// #Top_Interview_150_Backtracking #Big_O_Time_O(2^n)_Space_O(n) +// #2023_08_29_Time_60_ms_(62.03%)_Space_45.6_MB_(21.59%) function generateParenthesis(n: number): string[] { const sb: string[] = [] diff --git a/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts b/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts index b94cc7a..324c0f4 100644 --- a/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts +++ b/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Heap_Priority_Queue #Linked_List -// #Divide_and_Conquer #Merge_Sort #Big_O_Time_O(k*n*log(k))_Space_O(log(k)) -// #2023_10_09_Time_76_ms_(94.52%)_Space_47.9_MB_(84.35%) +// #Divide_and_Conquer #Merge_Sort #Top_Interview_150_Divide_and_Conquer +// #Big_O_Time_O(k*n*log(k))_Space_O(log(k)) #2023_10_09_Time_76_ms_(94.52%)_Space_47.9_MB_(84.35%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts b/src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts index 9f78202..f42aff4 100644 --- a/src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts +++ b/src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts @@ -1,5 +1,5 @@ // #Hard #Top_100_Liked_Questions #Linked_List #Recursion #Data_Structure_II_Day_13_Linked_List -// #Udemy_Linked_List #Big_O_Time_O(n)_Space_O(k) +// #Udemy_Linked_List #Top_Interview_150_Linked_List #Big_O_Time_O(n)_Space_O(k) // #2023_08_29_Time_74_ms_(66.83%)_Space_46.1_MB_(94.47%) /** diff --git a/src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts b/src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts index 4ec9c9c..79849e7 100644 --- a/src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts +++ b/src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search // #Algorithm_II_Day_1_Binary_Search #Binary_Search_I_Day_11 #Level_2_Day_8_Binary_Search -// #Udemy_Binary_Search #Big_O_Time_O(log_n)_Space_O(1) +// #Udemy_Binary_Search #Top_Interview_150_Binary_Search #Big_O_Time_O(log_n)_Space_O(1) // #2023_09_27_Time_43_ms_(98.54%)_Space_44.3_MB_(31.85%) function search(nums: number[], target: number): number { //NOSONAR diff --git a/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts b/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts index 32557da..c0d2498 100644 --- a/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts +++ b/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search -// #Algorithm_II_Day_1_Binary_Search #Binary_Search_I_Day_5 #Big_O_Time_O(log_n)_Space_O(1) -// #2023_09_27_Time_45_ms_(98.05%)_Space_44.5_MB_(54.86%) +// #Algorithm_II_Day_1_Binary_Search #Binary_Search_I_Day_5 #Top_Interview_150_Binary_Search +// #Big_O_Time_O(log_n)_Space_O(1) #2023_09_27_Time_45_ms_(98.05%)_Space_44.5_MB_(54.86%) function searchRange(nums: number[], target: number): number[] { //NOSONAR let first = -1 diff --git a/src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts b/src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts index 7aee8a4..094452a 100644 --- a/src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts +++ b/src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts @@ -1,5 +1,5 @@ // #Easy #Top_100_Liked_Questions #Array #Binary_Search #Algorithm_I_Day_1_Binary_Search -// #Binary_Search_I_Day_2 #Big_O_Time_O(log_n)_Space_O(1) +// #Binary_Search_I_Day_2 #Top_Interview_150_Binary_Search #Big_O_Time_O(log_n)_Space_O(1) // #2023_09_27_Time_51_ms_(80.95%)_Space_44.6_MB_(16.67%) function searchInsert(nums: number[], target: number): number { diff --git a/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts b/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts index fab12ba..e744ced 100644 --- a/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts +++ b/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Array #Backtracking #Algorithm_II_Day_10_Recursion_Backtracking // #Level_2_Day_20_Brute_Force/Backtracking #Udemy_Backtracking/Recursion -// #Big_O_Time_O(2^n)_Space_O(n+2^n) #2023_09_29_Time_65_ms_(86.86%)_Space_45.8_MB_(75.98%) +// #Top_Interview_150_Backtracking #Big_O_Time_O(2^n)_Space_O(n+2^n) +// #2023_09_29_Time_65_ms_(86.86%)_Space_45.8_MB_(75.98%) function combinationSum(candidates: number[], target: number): number[][] { const result: number[][] = [] diff --git a/src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts b/src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts index c65df74..4793367 100644 --- a/src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts +++ b/src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts @@ -1,6 +1,7 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming #Two_Pointers // #Stack #Monotonic_Stack #Dynamic_Programming_I_Day_9 #Udemy_Two_Pointers -// #Big_O_Time_O(n)_Space_O(1) #2023_09_30_Time_46_ms_(99.52%)_Space_44.4_MB_(97.58%) +// #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(1) +// #2023_09_30_Time_46_ms_(99.52%)_Space_44.4_MB_(97.58%) function trap(height: number[]): number { let result = 0 diff --git a/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts b/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts index ca06360..38c6277 100644 --- a/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts +++ b/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Greedy // #Algorithm_II_Day_13_Dynamic_Programming #Dynamic_Programming_I_Day_4 -// #Big_O_Time_O(n)_Space_O(1) #2023_09_30_Time_50_ms_(95.93%)_Space_44.9_MB_(65.88%) +// #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(1) +// #2023_09_30_Time_50_ms_(95.93%)_Space_44.9_MB_(65.88%) function jump(nums: number[]): number { //NOSONAR let minJmp = new Array(nums.length) diff --git a/src/main/ts/g0001_0100/s0046_permutations/solution.ts b/src/main/ts/g0001_0100/s0046_permutations/solution.ts index 2a97397..66ae2fc 100644 --- a/src/main/ts/g0001_0100/s0046_permutations/solution.ts +++ b/src/main/ts/g0001_0100/s0046_permutations/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Backtracking // #Algorithm_I_Day_11_Recursion_Backtracking #Level_2_Day_20_Brute_Force/Backtracking -// #Udemy_Backtracking/Recursion #Big_O_Time_O(n*n!)_Space_O(n+n!) +// #Udemy_Backtracking/Recursion #Top_Interview_150_Backtracking #Big_O_Time_O(n*n!)_Space_O(n+n!) // #2023_09_30_Time_56_ms_(96.26%)_Space_45.7_MB_(55.35%) function permute(nums: number[]): number[][] { diff --git a/src/main/ts/g0001_0100/s0048_rotate_image/solution.ts b/src/main/ts/g0001_0100/s0048_rotate_image/solution.ts index 8309b39..77241b2 100644 --- a/src/main/ts/g0001_0100/s0048_rotate_image/solution.ts +++ b/src/main/ts/g0001_0100/s0048_rotate_image/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Math #Matrix // #Data_Structure_II_Day_3_Array #Programming_Skills_II_Day_7 #Udemy_2D_Arrays/Matrix -// #Big_O_Time_O(n^2)_Space_O(1) #2023_09_30_Time_45_ms_(95.31%)_Space_44.4_MB_(48.24%) +// #Top_Interview_150_Matrix #Big_O_Time_O(n^2)_Space_O(1) +// #2023_09_30_Time_45_ms_(95.31%)_Space_44.4_MB_(48.24%) /* Do not return anything, modify matrix in-place instead. diff --git a/src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts b/src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts index 0e7e54d..c05a6db 100644 --- a/src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts +++ b/src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #String #Hash_Table #Sorting // #Data_Structure_II_Day_8_String #Programming_Skills_II_Day_11 #Udemy_Strings -// #Big_O_Time_O(n*k_log_k)_Space_O(n) #2023_09_30_Time_93_ms_(97.29%)_Space_52_MB_(99.08%) +// #Top_Interview_150_Hashmap #Big_O_Time_O(n*k_log_k)_Space_O(n) +// #2023_09_30_Time_93_ms_(97.29%)_Space_52_MB_(99.08%) function groupAnagrams(strs: string[]): string[][] { if (strs.length === 1) return [strs] diff --git a/src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts b/src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts index 7e5d91d..e301fea 100644 --- a/src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts +++ b/src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts @@ -1,6 +1,6 @@ -// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming +// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming // #Divide_and_Conquer #Data_Structure_I_Day_1_Array #Dynamic_Programming_I_Day_5 -// #Udemy_Famous_Algorithm #Big_O_Time_O(n)_Space_O(1) +// #Udemy_Famous_Algorithm #Top_Interview_150_Kadane's_Algorithm #Big_O_Time_O(n)_Space_O(1) // #2023_09_30_Time_66_ms_(90.36%)_Space_51.9_MB_(80.92%) function maxSubArray(nums: number[]): number { diff --git a/src/main/ts/g0001_0100/s0055_jump_game/solution.ts b/src/main/ts/g0001_0100/s0055_jump_game/solution.ts index 90097bb..c4b5936 100644 --- a/src/main/ts/g0001_0100/s0055_jump_game/solution.ts +++ b/src/main/ts/g0001_0100/s0055_jump_game/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming #Greedy // #Algorithm_II_Day_12_Dynamic_Programming #Dynamic_Programming_I_Day_4 #Udemy_Arrays -// #Big_O_Time_O(n)_Space_O(1) #2023_09_30_Time_58_ms_(91.95%)_Space_47.4_MB_(70.79%) +// #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(1) +// #2023_09_30_Time_58_ms_(91.95%)_Space_47.4_MB_(70.79%) function canJump(nums: number[]): boolean { let availableSteps = nums[0] diff --git a/src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts b/src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts index e67357b..d285a67 100644 --- a/src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts +++ b/src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting // #Data_Structure_II_Day_2_Array #Level_2_Day_17_Interval #Udemy_2D_Arrays/Matrix -// #Big_O_Time_O(n_log_n)_Space_O(n) #2023_10_01_Time_84_ms_(92.06%)_Space_49.9_MB_(69.16%) +// #Top_Interview_150_Intervals #Big_O_Time_O(n_log_n)_Space_O(n) +// #2023_10_01_Time_84_ms_(92.06%)_Space_49.9_MB_(69.16%) function merge(intervals: number[][]): number[][] { let result = [] diff --git a/src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts b/src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts index 2948ef7..7fc57a2 100644 --- a/src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts +++ b/src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Matrix -// #Dynamic_Programming_I_Day_16 #Udemy_Dynamic_Programming #Big_O_Time_O(m*n)_Space_O(m*n) -// #2023_10_01_Time_48_ms_(99.67%)_Space_44.5_MB_(90.16%) +// #Dynamic_Programming_I_Day_16 #Udemy_Dynamic_Programming #Top_Interview_150_Multidimensional_DP +// #Big_O_Time_O(m*n)_Space_O(m*n) #2023_10_01_Time_48_ms_(99.67%)_Space_44.5_MB_(90.16%) function minPathSum(grid: number[][]): number { let [m, n] = [grid.length, grid[0].length] diff --git a/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts b/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts index 93347d7..3746b9b 100644 --- a/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts +++ b/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Dynamic_Programming #Math #Memoization // #Algorithm_I_Day_12_Dynamic_Programming #Dynamic_Programming_I_Day_2 -// #Level_1_Day_10_Dynamic_Programming #Udemy_Dynamic_Programming #Big_O_Time_O(n)_Space_O(n) -// #2023_10_01_Time_44_ms_(94.58%)_Space_42.4_MB_(73.09%) +// #Level_1_Day_10_Dynamic_Programming #Udemy_Dynamic_Programming #Top_Interview_150_1D_DP +// #Big_O_Time_O(n)_Space_O(n) #2023_10_01_Time_44_ms_(94.58%)_Space_42.4_MB_(73.09%) function climbStairs(n: number, memo: Record = {}): number { if (n in memo) return memo[n] diff --git a/src/main/ts/g0001_0100/s0072_edit_distance/readme.md b/src/main/ts/g0001_0100/s0072_edit_distance/readme.md index fbd054c..75d48ed 100644 --- a/src/main/ts/g0001_0100/s0072_edit_distance/readme.md +++ b/src/main/ts/g0001_0100/s0072_edit_distance/readme.md @@ -1,6 +1,6 @@ 72\. Edit Distance -Hard +Medium Given two strings `word1` and `word2`, return _the minimum number of operations required to convert `word1` to `word2`_. diff --git a/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts b/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts index 58e4c6b..60c42f8 100644 --- a/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts +++ b/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts @@ -1,7 +1,7 @@ -// #Hard #Top_100_Liked_Questions #String #Dynamic_Programming +// #Medium #Top_100_Liked_Questions #String #Dynamic_Programming // #Algorithm_II_Day_18_Dynamic_Programming #Dynamic_Programming_I_Day_19 -// #Udemy_Dynamic_Programming #Big_O_Time_O(n^2)_Space_O(n2) -// #2023_10_01_Time_68_ms_(95.20%)_Space_47.3_MB_(78.40%) +// #Udemy_Dynamic_Programming #Top_Interview_150_Multidimensional_DP #Big_O_Time_O(n^2)_Space_O(n2) +// #2025_02_15_Time_9_ms_(93.59%)_Space_57.68_MB_(49.82%) function minDistance(word1: string, word2: string): number { const memo: number[][] = new Array(word1.length + 1).fill(0).map((_) => []) diff --git a/src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts b/src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts index 1500921..896c853 100644 --- a/src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts +++ b/src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Matrix -// #Udemy_2D_Arrays/Matrix #Big_O_Time_O(m*n)_Space_O(1) +// #Udemy_2D_Arrays/Matrix #Top_Interview_150_Matrix #Big_O_Time_O(m*n)_Space_O(1) // #2023_10_01_Time_61_ms_(97.66%)_Space_45.9_MB_(30.73%) /* diff --git a/src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts b/src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts index f0a582f..738defb 100644 --- a/src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts +++ b/src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Array #Binary_Search #Matrix #Data_Structure_I_Day_5_Array // #Algorithm_II_Day_1_Binary_Search #Binary_Search_I_Day_8 #Level_2_Day_8_Binary_Search -// #Udemy_2D_Arrays/Matrix #Big_O_Time_O(endRow+endCol)_Space_O(1) +// #Udemy_2D_Arrays/Matrix #Top_Interview_150_Binary_Search #Big_O_Time_O(endRow+endCol)_Space_O(1) // #2023_10_01_Time_45_ms_(96.82%)_Space_44.3_MB_(43.77%) function searchMatrix(matrix: number[][], target: number): boolean { diff --git a/src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts b/src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts index 10e234f..21b87ea 100644 --- a/src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts +++ b/src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Sliding_Window -// #Level_2_Day_14_Sliding_Window/Two_Pointer #Big_O_Time_O(s.length())_Space_O(1) -// #2023_10_02_Time_82_ms_(82.17%)_Space_46.2_MB_(81.89%) +// #Level_2_Day_14_Sliding_Window/Two_Pointer #Top_Interview_150_Sliding_Window +// #Big_O_Time_O(s.length())_Space_O(1) #2023_10_02_Time_82_ms_(82.17%)_Space_46.2_MB_(81.89%) function minWindow(s: string, t: string): string { //NOSONAR const map: Map = new Map() diff --git a/src/main/ts/g0001_0100/s0079_word_search/solution.ts b/src/main/ts/g0001_0100/s0079_word_search/solution.ts index d76d643..ffcd5ff 100644 --- a/src/main/ts/g0001_0100/s0079_word_search/solution.ts +++ b/src/main/ts/g0001_0100/s0079_word_search/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Matrix #Backtracking -// #Algorithm_II_Day_11_Recursion_Backtracking #Big_O_Time_O(4^(m*n))_Space_O(m*n) -// #2023_10_03_Time_327_ms_(95.78%)_Space_43.4_MB_(84.98%) +// #Algorithm_II_Day_11_Recursion_Backtracking #Top_Interview_150_Backtracking +// #Big_O_Time_O(4^(m*n))_Space_O(m*n) #2023_10_03_Time_327_ms_(95.78%)_Space_43.4_MB_(84.98%) function exist(board: string[][], word: string): boolean { if (word.length === 0) return false diff --git a/src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts b/src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts index c129e65..d080f77 100644 --- a/src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts +++ b/src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts @@ -1,5 +1,5 @@ -// #Medium #Top_100_Liked_Questions #Dynamic_Programming #Math #Tree #Binary_Tree -// #Binary_Search_Tree #Dynamic_Programming_I_Day_11 #Big_O_Time_O(n)_Space_O(1) +// #Medium #Dynamic_Programming #Math #Tree #Binary_Tree #Binary_Search_Tree +// #Dynamic_Programming_I_Day_11 #Big_O_Time_O(n)_Space_O(1) // #2023_10_03_Time_45_ms_(96.00%)_Space_42.9_MB_(25.33%) function numTrees(n: number): number { diff --git a/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts b/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts index 3e277a4..4ad9c1a 100644 --- a/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts +++ b/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Tree #Binary_Tree // #Binary_Search_Tree #Data_Structure_I_Day_14_Tree #Level_1_Day_8_Binary_Search_Tree -// #Udemy_Tree_Stack_Queue #Big_O_Time_O(N)_Space_O(log(N)) +// #Udemy_Tree_Stack_Queue #Top_Interview_150_Binary_Search_Tree #Big_O_Time_O(N)_Space_O(log(N)) // #2023_10_03_Time_51_ms_(98.35%)_Space_47.3_MB_(61.68%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts b/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts index 8c4b109..32242f0 100644 --- a/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts +++ b/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts @@ -1,6 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Breadth_First_Search // #Tree #Binary_Tree #Data_Structure_I_Day_11_Tree #Level_2_Day_15_Tree -// #Big_O_Time_O(N)_Space_O(log(N)) #2023_10_04_Time_49_ms_(98.54%)_Space_45_MB_(59.02%) +// #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(N)_Space_O(log(N)) +// #2023_10_04_Time_49_ms_(98.54%)_Space_45_MB_(59.02%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts b/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts index c7ad922..257f624 100644 --- a/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts +++ b/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Breadth_First_Search #Tree // #Binary_Tree #Data_Structure_I_Day_11_Tree #Level_1_Day_6_Tree #Udemy_Tree_Stack_Queue -// #Big_O_Time_O(N)_Space_O(N) #2023_10_04_Time_60_ms_(97.47%)_Space_47_MB_(77.89%) +// #Top_Interview_150_Binary_Tree_BFS #Big_O_Time_O(N)_Space_O(N) +// #2023_10_04_Time_60_ms_(97.47%)_Space_47_MB_(77.89%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts b/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts index 0956744..1efe28d 100644 --- a/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts +++ b/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts @@ -1,7 +1,8 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Breadth_First_Search // #Tree #Binary_Tree #Data_Structure_I_Day_11_Tree // #Programming_Skills_I_Day_10_Linked_List_and_Tree #Udemy_Tree_Stack_Queue -// #Big_O_Time_O(N)_Space_O(H) #2023_10_04_Time_51_ms_(97.14%)_Space_46.1_MB_(68.29%) +// #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(N)_Space_O(H) +// #2023_10_04_Time_51_ms_(97.14%)_Space_46.1_MB_(68.29%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts b/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts index 2489097..dababbe 100644 --- a/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts +++ b/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Tree #Binary_Tree -// #Divide_and_Conquer #Data_Structure_II_Day_15_Tree #Big_O_Time_O(N)_Space_O(N) -// #2023_10_04_Time_65_ms_(96.47%)_Space_45.9_MB_(80.00%) +// #Divide_and_Conquer #Data_Structure_II_Day_15_Tree #Top_Interview_150_Binary_Tree_General +// #Big_O_Time_O(N)_Space_O(N) #2023_10_04_Time_65_ms_(96.47%)_Space_45.9_MB_(80.00%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts b/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts index 449dae4..5941397 100644 --- a/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts +++ b/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree #Stack #Linked_List -// #Udemy_Linked_List #Big_O_Time_O(N)_Space_O(N) +// #Udemy_Linked_List #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(N)_Space_O(N) // #2023_10_04_Time_55_ms_(90.66%)_Space_45.8_MB_(12.11%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts b/src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts index b91860d..11b0445 100644 --- a/src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts +++ b/src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts @@ -1,6 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming // #Data_Structure_I_Day_3_Array #Dynamic_Programming_I_Day_7 #Level_1_Day_5_Greedy #Udemy_Arrays -// #Big_O_Time_O(N)_Space_O(1) #2023_10_05_Time_56_ms_(99.56%)_Space_52.3_MB_(13.22%) +// #Top_Interview_150_Array/String #Big_O_Time_O(N)_Space_O(1) +// #2023_10_05_Time_56_ms_(99.56%)_Space_52.3_MB_(13.22%) function maxProfit(prices: number[]): number { let buyPrice = prices[0] diff --git a/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts b/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts index 923d6db..1118a0f 100644 --- a/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts +++ b/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Dynamic_Programming #Depth_First_Search -// #Tree #Binary_Tree #Udemy_Tree_Stack_Queue #Big_O_Time_O(N)_Space_O(N) -// #2023_10_05_Time_61_ms_(96.73%)_Space_51.2_MB_(97.45%) +// #Tree #Binary_Tree #Udemy_Tree_Stack_Queue #Top_Interview_150_Binary_Tree_General +// #Big_O_Time_O(N)_Space_O(N) #2023_10_05_Time_61_ms_(96.73%)_Space_51.2_MB_(97.45%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts b/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts index aa55676..e69031e 100644 --- a/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts +++ b/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts @@ -1,5 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Union_Find -// #Big_O_Time_O(N_log_N)_Space_O(1) #2023_10_05_Time_92_ms_(93.69%)_Space_64_MB_(30.13%) +// #Top_Interview_150_Hashmap #Big_O_Time_O(N_log_N)_Space_O(1) +// #2023_10_05_Time_92_ms_(93.69%)_Space_64_MB_(30.13%) function longestConsecutive(nums: number[]): number { const set = new Set(nums) diff --git a/src/main/ts/g0101_0200/s0136_single_number/solution.ts b/src/main/ts/g0101_0200/s0136_single_number/solution.ts index 4f569f0..cc5faaf 100644 --- a/src/main/ts/g0101_0200/s0136_single_number/solution.ts +++ b/src/main/ts/g0101_0200/s0136_single_number/solution.ts @@ -1,6 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Bit_Manipulation // #Data_Structure_II_Day_1_Array #Algorithm_I_Day_14_Bit_Manipulation #Udemy_Integers -// #Big_O_Time_O(N)_Space_O(1) #2023_10_05_Time_56_ms_(85.48%)_Space_45.6_MB_(63.32%) +// #Top_Interview_150_Bit_Manipulation #Big_O_Time_O(N)_Space_O(1) +// #2023_10_05_Time_56_ms_(85.48%)_Space_45.6_MB_(63.32%) function singleNumber(nums: number[]): number { let ans = 0 diff --git a/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts b/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts index cabd0ff..b633e45 100644 --- a/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts +++ b/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Linked_List -// #Programming_Skills_II_Day_14 #Udemy_Linked_List #Big_O_Time_O(N)_Space_O(N) -// #2023_10_06_Time_52_ms_(88.27%)_Space_44.7_MB_(72.42%) +// #Programming_Skills_II_Day_14 #Udemy_Linked_List #Top_Interview_150_Linked_List +// #Big_O_Time_O(N)_Space_O(N) #2023_10_06_Time_52_ms_(88.27%)_Space_44.7_MB_(72.42%) import { Node } from '../../com_github_leetcode/node' diff --git a/src/main/ts/g0101_0200/s0139_word_break/solution.ts b/src/main/ts/g0101_0200/s0139_word_break/solution.ts index 00ccbdc..bba50d9 100644 --- a/src/main/ts/g0101_0200/s0139_word_break/solution.ts +++ b/src/main/ts/g0101_0200/s0139_word_break/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table // #Dynamic_Programming #Trie #Memoization #Algorithm_II_Day_15_Dynamic_Programming -// #Dynamic_Programming_I_Day_9 #Udemy_Dynamic_Programming #Big_O_Time_O(M+max*N)_Space_O(M+N+max) -// #2023_10_06_Time_56_ms_(88.44%)_Space_44.1_MB_(93.39%) +// #Dynamic_Programming_I_Day_9 #Udemy_Dynamic_Programming #Top_Interview_150_1D_DP +// #Big_O_Time_O(M+max*N)_Space_O(M+N+max) #2023_10_06_Time_56_ms_(88.44%)_Space_44.1_MB_(93.39%) function wordBreak(s: string, wordDict: string[]): boolean { const dp: boolean[] = [] diff --git a/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts b/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts index 56e2c6b..ffdf669 100644 --- a/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts +++ b/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Two_Pointers #Linked_List -// #Data_Structure_I_Day_7_Linked_List #Udemy_Linked_List #Big_O_Time_O(N)_Space_O(1) -// #2023_10_06_Time_59_ms_(93.37%)_Space_45.2_MB_(76.28%) +// #Data_Structure_I_Day_7_Linked_List #Udemy_Linked_List #Top_Interview_150_Linked_List +// #Big_O_Time_O(N)_Space_O(1) #2023_10_06_Time_59_ms_(93.37%)_Space_45.2_MB_(76.28%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0101_0200/s0146_lru_cache/solution.ts b/src/main/ts/g0101_0200/s0146_lru_cache/solution.ts index 76159e6..e36ba1e 100644 --- a/src/main/ts/g0101_0200/s0146_lru_cache/solution.ts +++ b/src/main/ts/g0101_0200/s0146_lru_cache/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Design #Linked_List -// #Doubly_Linked_List #Udemy_Linked_List #Big_O_Time_O(1)_Space_O(capacity) -// #2023_10_06_Time_473_ms_(94.72%)_Space_125.1_MB_(69.62%) +// #Doubly_Linked_List #Udemy_Linked_List #Top_Interview_150_Linked_List +// #Big_O_Time_O(1)_Space_O(capacity) #2023_10_06_Time_473_ms_(94.72%)_Space_125.1_MB_(69.62%) interface ICacheNode { key: number diff --git a/src/main/ts/g0101_0200/s0148_sort_list/solution.ts b/src/main/ts/g0101_0200/s0148_sort_list/solution.ts index 4151a30..a6a411e 100644 --- a/src/main/ts/g0101_0200/s0148_sort_list/solution.ts +++ b/src/main/ts/g0101_0200/s0148_sort_list/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Sorting #Two_Pointers #Linked_List -// #Divide_and_Conquer #Merge_Sort #Level_2_Day_4_Linked_List #Big_O_Time_O(log(N))_Space_O(log(N)) -// #2023_10_08_Time_141_ms_(97.14%)_Space_71.9_MB_(47.35%) +// #Divide_and_Conquer #Merge_Sort #Level_2_Day_4_Linked_List #Top_Interview_150_Divide_and_Conquer +// #Big_O_Time_O(log(N))_Space_O(log(N)) #2023_10_08_Time_141_ms_(97.14%)_Space_71.9_MB_(47.35%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts b/src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts index c8c4ea3..02e0617 100644 --- a/src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts +++ b/src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Array #Binary_Search #Algorithm_II_Day_2_Binary_Search -// #Binary_Search_I_Day_12 #Udemy_Binary_Search #Big_O_Time_O(log_N)_Space_O(log_N) -// #2023_10_08_Time_42_ms_(98.87%)_Space_42.9_MB_(84.75%) +// #Binary_Search_I_Day_12 #Udemy_Binary_Search #Top_Interview_150_Binary_Search +// #Big_O_Time_O(log_N)_Space_O(log_N) #2023_10_08_Time_42_ms_(98.87%)_Space_42.9_MB_(84.75%) function findMin(nums: number[]): number { return Math.min(...nums) diff --git a/src/main/ts/g0101_0200/s0155_min_stack/solution.ts b/src/main/ts/g0101_0200/s0155_min_stack/solution.ts index 9912e0f..68fbd2b 100644 --- a/src/main/ts/g0101_0200/s0155_min_stack/solution.ts +++ b/src/main/ts/g0101_0200/s0155_min_stack/solution.ts @@ -1,6 +1,7 @@ -// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Stack #Design +// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Stack #Design // #Data_Structure_II_Day_14_Stack_Queue #Programming_Skills_II_Day_18 #Level_2_Day_16_Design -// #Udemy_Design #Big_O_Time_O(1)_Space_O(N) #2023_10_08_Time_84_ms_(92.72%)_Space_51.8_MB_(30.46%) +// #Udemy_Design #Top_Interview_150_Stack #Big_O_Time_O(1)_Space_O(N) +// #2023_10_08_Time_84_ms_(92.72%)_Space_51.8_MB_(30.46%) class MinStack { stack: number[] diff --git a/src/main/ts/g0101_0200/s0169_majority_element/solution.ts b/src/main/ts/g0101_0200/s0169_majority_element/solution.ts index e394d69..ab52770 100644 --- a/src/main/ts/g0101_0200/s0169_majority_element/solution.ts +++ b/src/main/ts/g0101_0200/s0169_majority_element/solution.ts @@ -1,6 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Sorting #Counting // #Divide_and_Conquer #Data_Structure_II_Day_1_Array #Udemy_Famous_Algorithm -// #Big_O_Time_O(n)_Space_O(1) #2023_10_09_Time_50_ms_(96.16%)_Space_46.1_MB_(46.90%) +// #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(1) +// #2023_10_09_Time_50_ms_(96.16%)_Space_46.1_MB_(46.90%) function majorityElement(arr: number[]): number { let count = 1 diff --git a/src/main/ts/g0101_0200/s0189_rotate_array/solution.ts b/src/main/ts/g0101_0200/s0189_rotate_array/solution.ts index b6c7b1e..ca7b07f 100644 --- a/src/main/ts/g0101_0200/s0189_rotate_array/solution.ts +++ b/src/main/ts/g0101_0200/s0189_rotate_array/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Math #Two_Pointers -// #Algorithm_I_Day_2_Two_Pointers #Udemy_Arrays #Big_O_Time_O(n)_Space_O(1) -// #2023_10_09_Time_75_ms_(97.25%)_Space_52_MB_(63.34%) +// #Algorithm_I_Day_2_Two_Pointers #Udemy_Arrays #Top_Interview_150_Array/String +// #Big_O_Time_O(n)_Space_O(1) #2023_10_09_Time_75_ms_(97.25%)_Space_52_MB_(63.34%) /* Do not return anything, modify nums in-place instead. diff --git a/src/main/ts/g0101_0200/s0198_house_robber/solution.ts b/src/main/ts/g0101_0200/s0198_house_robber/solution.ts index 6b1c436..1dba115 100644 --- a/src/main/ts/g0101_0200/s0198_house_robber/solution.ts +++ b/src/main/ts/g0101_0200/s0198_house_robber/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming // #Algorithm_I_Day_12_Dynamic_Programming #Dynamic_Programming_I_Day_3 -// #Level_2_Day_12_Dynamic_Programming #Udemy_Dynamic_Programming #Big_O_Time_O(n)_Space_O(n) -// #2023_10_09_Time_51_ms_(77.29%)_Space_42.7_MB_(62.58%) +// #Level_2_Day_12_Dynamic_Programming #Udemy_Dynamic_Programming #Top_Interview_150_1D_DP +// #Big_O_Time_O(n)_Space_O(n) #2023_10_09_Time_51_ms_(77.29%)_Space_42.7_MB_(62.58%) function rob(nums: number[]): number { const n = nums.length diff --git a/src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts b/src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts index db5cfb0..5408d4f 100644 --- a/src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts +++ b/src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts @@ -2,7 +2,8 @@ // #Breadth_First_Search #Matrix #Union_Find // #Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search // #Graph_Theory_I_Day_1_Matrix_Related_Problems #Level_1_Day_9_Graph/BFS/DFS #Udemy_Graph -// #Big_O_Time_O(M*N)_Space_O(M*N) #2023_10_09_Time_61_ms_(96.71%)_Space_44.5_MB_(99.30%) +// #Top_Interview_150_Graph_General #Big_O_Time_O(M*N)_Space_O(M*N) +// #2023_10_09_Time_61_ms_(96.71%)_Space_44.5_MB_(99.30%) function numIslands(grid: string[][]): number { let islands = 0 diff --git a/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts b/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts index db5be9f..dd108fa 100644 --- a/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts +++ b/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search -// #Breadth_First_Search #Graph #Topological_Sort #Big_O_Time_O(N)_Space_O(N) -// #2023_10_09_Time_68_ms_(70.14%)_Space_47.7_MB_(73.55%) +// #Breadth_First_Search #Graph #Topological_Sort #Top_Interview_150_Graph_General +// #Big_O_Time_O(N)_Space_O(N) #2023_10_09_Time_68_ms_(70.14%)_Space_47.7_MB_(73.55%) const WHITE = 0 const GRAY = 1 diff --git a/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts b/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts index aafabc9..24f299b 100644 --- a/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts +++ b/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Design #Trie -// #Level_2_Day_16_Design #Udemy_Trie_and_Heap +// #Level_2_Day_16_Design #Udemy_Trie_and_Heap #Top_Interview_150_Trie // #Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) // #2023_10_09_Time_168_ms_(80.99%)_Space_79.5_MB_(14.46%) diff --git a/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts b/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts index bc2ec15..ed7e619 100644 --- a/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts +++ b/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting #Heap_Priority_Queue // #Divide_and_Conquer #Quickselect #Data_Structure_II_Day_20_Heap_Priority_Queue -// #Big_O_Time_O(n*log(n))_Space_O(log(n)) #2023_10_09_Time_148_ms_(54.45%)_Space_51.5_MB_(73.60%) +// #Top_Interview_150_Heap #Big_O_Time_O(n*log(n))_Space_O(log(n)) +// #2023_10_09_Time_148_ms_(54.45%)_Space_51.5_MB_(73.60%) function findKthLargest(nums: number[], k: number): number { nums.sort((prev, next) => next - prev) diff --git a/src/main/ts/g0201_0300/s0221_maximal_square/solution.ts b/src/main/ts/g0201_0300/s0221_maximal_square/solution.ts index 10aa2ce..0137581 100644 --- a/src/main/ts/g0201_0300/s0221_maximal_square/solution.ts +++ b/src/main/ts/g0201_0300/s0221_maximal_square/solution.ts @@ -1,5 +1,5 @@ -// #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Matrix -// #Dynamic_Programming_I_Day_16 #Big_O_Time_O(m*n)_Space_O(m*n) +// #Medium #Array #Dynamic_Programming #Matrix #Dynamic_Programming_I_Day_16 +// #Top_Interview_150_Multidimensional_DP #Big_O_Time_O(m*n)_Space_O(m*n) // #2023_10_09_Time_83_ms_(79.70%)_Space_50.2_MB_(56.39%) function maximalSquare(matrix: string[][]): number { diff --git a/src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts b/src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts index 4f1b49c..2b2a6d4 100644 --- a/src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts +++ b/src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts @@ -1,6 +1,7 @@ // #Easy #Top_100_Liked_Questions #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree // #Data_Structure_I_Day_12_Tree #Level_2_Day_6_Tree #Udemy_Tree_Stack_Queue -// #Big_O_Time_O(n)_Space_O(n) #2023_10_09_Time_52_ms_(81.65%)_Space_44.2_MB_(79.49%) +// #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(n)_Space_O(n) +// #2023_10_09_Time_52_ms_(81.65%)_Space_44.2_MB_(79.49%) function invertTree(root: TreeNode | null): TreeNode | null { if (root === null) { diff --git a/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts b/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts index c40c632..53cb174 100644 --- a/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts +++ b/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts @@ -1,6 +1,7 @@ -// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Tree #Binary_Tree -// #Binary_Search_Tree #Data_Structure_II_Day_17_Tree #Level_2_Day_9_Binary_Search_Tree -// #Big_O_Time_O(n)_Space_O(n) #2023_10_09_Time_54_ms_(97.22%)_Space_47.7_MB_(99.80%) +// #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree #Binary_Search_Tree +// #Data_Structure_II_Day_17_Tree #Level_2_Day_9_Binary_Search_Tree +// #Top_Interview_150_Binary_Search_Tree #Big_O_Time_O(n)_Space_O(n) +// #2023_10_09_Time_54_ms_(97.22%)_Space_47.7_MB_(99.80%) /* * Definition for a binary tree node. diff --git a/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts b/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts index 32ca9be..aedaef3 100644 --- a/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts +++ b/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts @@ -1,5 +1,5 @@ -// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Two_Pointers #Stack #Linked_List -// #Recursion #Level_2_Day_3_Linked_List #Udemy_Linked_List #Big_O_Time_O(n)_Space_O(1) +// #Easy #Top_100_Liked_Questions #Two_Pointers #Stack #Linked_List #Recursion +// #Level_2_Day_3_Linked_List #Udemy_Linked_List #Big_O_Time_O(n)_Space_O(1) // #2023_10_09_Time_96_ms_(95.67%)_Space_72.8_MB_(87.01%) /* diff --git a/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts b/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts index 4d770b3..7823021 100644 --- a/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts +++ b/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts @@ -1,6 +1,6 @@ -// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Tree #Binary_Tree -// #Data_Structure_II_Day_18_Tree #Udemy_Tree_Stack_Queue #Big_O_Time_O(n)_Space_O(n) -// #2023_10_09_Time_59_ms_(96.11%)_Space_52.8_MB_(24.18%) +// #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree +// #Data_Structure_II_Day_18_Tree #Udemy_Tree_Stack_Queue #Top_Interview_150_Binary_Tree_General +// #Big_O_Time_O(n)_Space_O(n) #2023_10_09_Time_59_ms_(96.11%)_Space_52.8_MB_(24.18%) /* * Definition for a binary tree node. diff --git a/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts b/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts index cded71d..811e0a7 100644 --- a/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts +++ b/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts @@ -1,5 +1,5 @@ -// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Prefix_Sum -// #Data_Structure_II_Day_5_Array #Udemy_Arrays #Big_O_Time_O(n^2)_Space_O(n) +// #Medium #Top_100_Liked_Questions #Array #Prefix_Sum #Data_Structure_II_Day_5_Array #Udemy_Arrays +// #Top_Interview_150_Array/String #Big_O_Time_O(n^2)_Space_O(n) // #2023_10_09_Time_89_ms_(64.48%)_Space_55.4_MB_(36.71%) function productExceptSelf(nums: number[]): number[] { diff --git a/src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts b/src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts index 4d38555..699f267 100644 --- a/src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts +++ b/src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts @@ -1,5 +1,5 @@ -// #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Heap_Priority_Queue -// #Sliding_Window #Queue #Monotonic_Queue #Udemy_Arrays #Big_O_Time_O(n*k)_Space_O(n+k) +// #Hard #Top_100_Liked_Questions #Array #Heap_Priority_Queue #Sliding_Window #Queue +// #Monotonic_Queue #Udemy_Arrays #Big_O_Time_O(n*k)_Space_O(n+k) // #2023_10_06_Time_216_ms_(99.50%)_Space_71.4_MB_(89.85%) function maxSlidingWindow(nums: number[], k: number): number[] { diff --git a/src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts b/src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts index ee06606..f0c503d 100644 --- a/src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts +++ b/src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts @@ -1,6 +1,6 @@ -// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search #Matrix -// #Divide_and_Conquer #Data_Structure_II_Day_4_Array #Binary_Search_II_Day_8 -// #Big_O_Time_O(n+m)_Space_O(1) #2023_10_06_Time_58_ms_(64.44%)_Space_45.6_MB_(50.00%) +// #Medium #Top_100_Liked_Questions #Array #Binary_Search #Matrix #Divide_and_Conquer +// #Data_Structure_II_Day_4_Array #Binary_Search_II_Day_8 #Big_O_Time_O(n+m)_Space_O(1) +// #2023_10_06_Time_58_ms_(64.44%)_Space_45.6_MB_(50.00%) function searchMatrix(matrix: number[][], target: number): boolean { let r: number = 0 diff --git a/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts b/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts index 98ef336..7ef6a9b 100644 --- a/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts +++ b/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts @@ -1,6 +1,6 @@ -// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Two_Pointers -// #Algorithm_I_Day_3_Two_Pointers #Programming_Skills_I_Day_6_Array #Udemy_Arrays -// #Big_O_Time_O(n)_Space_O(1) #2023_10_06_Time_71_ms_(91.63%)_Space_47.2_MB_(57.52%) +// #Easy #Top_100_Liked_Questions #Array #Two_Pointers #Algorithm_I_Day_3_Two_Pointers +// #Programming_Skills_I_Day_6_Array #Udemy_Arrays #Big_O_Time_O(n)_Space_O(1) +// #2023_10_06_Time_71_ms_(91.63%)_Space_47.2_MB_(57.52%) /* Do not return anything, modify nums in-place instead. diff --git a/src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts b/src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts index 02a43b7..dc8ada3 100644 --- a/src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts +++ b/src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts @@ -1,5 +1,5 @@ -// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search #Two_Pointers -// #Bit_Manipulation #Binary_Search_II_Day_5 #Big_O_Time_O(n)_Space_O(n) +// #Medium #Top_100_Liked_Questions #Array #Binary_Search #Two_Pointers #Bit_Manipulation +// #Binary_Search_II_Day_5 #Big_O_Time_O(n)_Space_O(n) // #2023_10_06_Time_60_ms_(98.11%)_Space_53.5_MB_(50.00%) function findDuplicate(nums: number[]): number { diff --git a/src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts b/src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts index d429c85..b46275f 100644 --- a/src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts +++ b/src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts @@ -1,5 +1,5 @@ -// #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Sorting #Two_Pointers #Design -// #Heap_Priority_Queue #Data_Stream #Big_O_Time_O(n*log_n)_Space_O(n) +// #Hard #Top_100_Liked_Questions #Sorting #Two_Pointers #Design #Heap_Priority_Queue #Data_Stream +// #Top_Interview_150_Heap #Big_O_Time_O(n*log_n)_Space_O(n) // #2023_10_13_Time_335_ms_(99.44%)_Space_96.8_MB_(69.49%) class Heap { diff --git a/src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts b/src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts index 742db90..0c459e9 100644 --- a/src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts +++ b/src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts @@ -1,6 +1,6 @@ -// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming -// #Binary_Search #Algorithm_II_Day_16_Dynamic_Programming #Binary_Search_II_Day_3 -// #Dynamic_Programming_I_Day_18 #Udemy_Dynamic_Programming #Big_O_Time_O(n*log_n)_Space_O(n) +// #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Binary_Search +// #Algorithm_II_Day_16_Dynamic_Programming #Binary_Search_II_Day_3 #Dynamic_Programming_I_Day_18 +// #Udemy_Dynamic_Programming #Top_Interview_150_1D_DP #Big_O_Time_O(n*log_n)_Space_O(n) // #2023_10_04_Time_57_ms_(93.75%)_Space_45_MB_(33.55%) function lengthOfLIS(nums: number[]): number { diff --git a/src/main/ts/g0301_0400/s0322_coin_change/solution.ts b/src/main/ts/g0301_0400/s0322_coin_change/solution.ts index d91f8c6..9fb67cd 100644 --- a/src/main/ts/g0301_0400/s0322_coin_change/solution.ts +++ b/src/main/ts/g0301_0400/s0322_coin_change/solution.ts @@ -1,6 +1,6 @@ -// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming -// #Breadth_First_Search #Algorithm_II_Day_18_Dynamic_Programming #Dynamic_Programming_I_Day_20 -// #Level_2_Day_12_Dynamic_Programming #Big_O_Time_O(m*n)_Space_O(amount) +// #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Breadth_First_Search +// #Algorithm_II_Day_18_Dynamic_Programming #Dynamic_Programming_I_Day_20 +// #Level_2_Day_12_Dynamic_Programming #Top_Interview_150_1D_DP #Big_O_Time_O(m*n)_Space_O(amount) // #2023_10_04_Time_85_ms_(86.14%)_Space_47.7_MB_(84.40%) function coinChange(coins: number[], amount: number): number { diff --git a/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts b/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts index 8ff56ee..07708da 100644 --- a/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts +++ b/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts @@ -1,4 +1,4 @@ -// #Easy #Top_100_Liked_Questions #Dynamic_Programming #Bit_Manipulation #Udemy_Bit_Manipulation +// #Easy #Dynamic_Programming #Bit_Manipulation #Udemy_Bit_Manipulation // #Big_O_Time_O(num)_Space_O(num) #2023_10_04_Time_69_ms_(86.81%)_Space_49_MB_(78.01%) function countBits(n: number): number[] { diff --git a/src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts b/src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts index ee32d6e..fcc2d4b 100644 --- a/src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts +++ b/src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts @@ -1,7 +1,6 @@ -// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Sorting -// #Heap_Priority_Queue #Counting #Divide_and_Conquer #Quickselect #Bucket_Sort -// #Data_Structure_II_Day_20_Heap_Priority_Queue #Big_O_Time_O(n*log(n))_Space_O(k) -// #2023_10_04_Time_62_ms_(87.48%)_Space_45.6_MB_(67.84%) +// #Medium #Top_100_Liked_Questions #Array #Hash_Table #Sorting #Heap_Priority_Queue #Counting +// #Divide_and_Conquer #Quickselect #Bucket_Sort #Data_Structure_II_Day_20_Heap_Priority_Queue +// #Big_O_Time_O(n*log(n))_Space_O(k) #2023_10_04_Time_62_ms_(87.48%)_Space_45.6_MB_(67.84%) function topKFrequent(nums: number[], k: number): number[] { let elementCount = new Array(nums.length) diff --git a/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts b/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts index 9a2b73b..266804a 100644 --- a/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts +++ b/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts @@ -1,5 +1,5 @@ -// #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree #Level_2_Day_7_Tree -// #Big_O_Time_O(n)_Space_O(n) #2023_09_30_Time_68_ms_(86.71%)_Space_47.3_MB_(98.10%) +// #Medium #Depth_First_Search #Tree #Binary_Tree #Level_2_Day_7_Tree #Big_O_Time_O(n)_Space_O(n) +// #2023_09_30_Time_68_ms_(86.71%)_Space_47.3_MB_(98.10%) function pathSum(root: TreeNode | null, targetSum: number): number { let count = 0 diff --git a/src/main/ts/g0401_0500/s0494_target_sum/solution.ts b/src/main/ts/g0401_0500/s0494_target_sum/solution.ts index c6fe322..1dddfb5 100644 --- a/src/main/ts/g0401_0500/s0494_target_sum/solution.ts +++ b/src/main/ts/g0401_0500/s0494_target_sum/solution.ts @@ -1,5 +1,4 @@ -// #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Backtracking -// #Big_O_Time_O(n*(sum+s))_Space_O(n*(sum+s)) +// #Medium #Array #Dynamic_Programming #Backtracking #Big_O_Time_O(n*(sum+s))_Space_O(n*(sum+s)) // #2023_09_30_Time_77_ms_(81.99%)_Space_48.3_MB_(62.73%) function findTargetSumWays(nums: number[], s: number): number { diff --git a/src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts b/src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts index e97f100..4c31fc3 100644 --- a/src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts +++ b/src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts @@ -1,4 +1,4 @@ -// #Medium #Top_100_Liked_Questions #String #Dynamic_Programming #Big_O_Time_O(n^2)_Space_O(n) +// #Medium #String #Dynamic_Programming #Big_O_Time_O(n^2)_Space_O(n) // #2023_09_30_Time_60_ms_(89.76%)_Space_43_MB_(93.98%) function expand(a: string[], l: number, r: number, res: number[]): void { diff --git a/src/main/ts/g0701_0800/s0763_partition_labels/solution.ts b/src/main/ts/g0701_0800/s0763_partition_labels/solution.ts index 2cdf78f..b9b2a63 100644 --- a/src/main/ts/g0701_0800/s0763_partition_labels/solution.ts +++ b/src/main/ts/g0701_0800/s0763_partition_labels/solution.ts @@ -1,6 +1,5 @@ -// #Medium #Top_100_Liked_Questions #String #Hash_Table #Greedy #Two_Pointers -// #Data_Structure_II_Day_7_String #Big_O_Time_O(n)_Space_O(1) -// #2023_09_30_Time_54_ms_(94.74%)_Space_45.2_MB_(56.58%) +// #Medium #String #Hash_Table #Greedy #Two_Pointers #Data_Structure_II_Day_7_String +// #Big_O_Time_O(n)_Space_O(1) #2025_02_15_Time_3_ms_(97.96%)_Space_52.21_MB_(88.78%) function partitionLabels(s: string): number[] { const map = new Map() From 314fc93043c31563a9a35d9c49bd7ad29272346b Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sat, 22 Mar 2025 16:35:57 +0200 Subject: [PATCH 12/49] Improved tasks 1-39 --- README.md | 354 +++++++++--------- .../ts/g0001_0100/s0001_two_sum/solution.ts | 2 +- .../s0002_add_two_numbers/solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../s0006_zigzag_conversion/solution.ts | 2 +- .../s0007_reverse_integer/solution.ts | 2 +- .../s0008_string_to_integer_atoi/solution.ts | 2 +- .../s0009_palindrome_number/solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- src/main/ts/g0001_0100/s0015_3sum/solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../s0020_valid_parentheses/solution.ts | 2 +- .../s0021_merge_two_sorted_lists/solution.ts | 2 +- .../s0022_generate_parentheses/solution.ts | 2 +- .../s0023_merge_k_sorted_lists/solution.ts | 2 +- .../s0024_swap_nodes_in_pairs/solution.ts | 2 +- .../solution.ts | 2 +- .../s0031_next_permutation/solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../s0035_search_insert_position/solution.ts | 2 +- .../s0039_combination_sum/solution.ts | 2 +- 27 files changed, 203 insertions(+), 203 deletions(-) diff --git a/README.md b/README.md index 1abeed6..8e28190 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) ## -* [Algorithm I](#algorithm-i) * [Algorithm II](#algorithm-ii) * [Binary Search I](#binary-search-i) * [Binary Search II](#binary-search-ii) @@ -27,89 +26,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. * [Top Interview 150](#top-interview-150) * [Data Structure I](#data-structure-i) * [Data Structure II](#data-structure-ii) - -### Algorithm I - -#### Day 1 Binary Search - -| | | | | | -|-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 - -#### Day 2 Two Pointers - -| | | | | | -|-|-|-|-|-|- -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 - -#### Day 3 Two Pointers - -| | | | | | -|-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 - -#### Day 4 Two Pointers - -| | | | | | -|-|-|-|-|-|- - -#### Day 5 Two Pointers - -| | | | | | -|-|-|-|-|-|- -| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 - -#### Day 6 Sliding Window - -| | | | | | -|-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 - -#### Day 7 Breadth First Search Depth First Search - -| | | | | | -|-|-|-|-|-|- - -#### Day 8 Breadth First Search Depth First Search - -| | | | | | -|-|-|-|-|-|- - -#### Day 9 Breadth First Search Depth First Search - -| | | | | | -|-|-|-|-|-|- - -#### Day 10 Recursion Backtracking - -| | | | | | -|-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 - -#### Day 11 Recursion Backtracking - -| | | | | | -|-|-|-|-|-|- -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 - -#### Day 12 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 - -#### Day 13 Bit Manipulation - -| | | | | | -|-|-|-|-|-|- - -#### Day 14 Bit Manipulation - -| | | | | | -|-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +* [Algorithm I](#algorithm-i) ### Algorithm II @@ -117,8 +34,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 #### Day 2 Binary Search @@ -131,13 +48,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 #### Day 4 Two Pointers | | | | | | |-|-|-|-|-|- -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 #### Day 5 Sliding Window @@ -171,14 +88,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 #### Day 11 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 | 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 #### Day 12 Dynamic Programming @@ -198,7 +115,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 #### Day 15 Dynamic Programming @@ -222,7 +139,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 #### Day 19 Bit Manipulation @@ -251,7 +168,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 #### Day 3 @@ -267,7 +184,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 #### Day 6 @@ -299,7 +216,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 #### Day 12 @@ -511,7 +428,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 #### Day 18 @@ -524,7 +441,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 #### Day 20 @@ -682,7 +599,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 92 | 77.86 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 2 | 95.82 #### Day 16 @@ -851,7 +768,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 | 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 #### Day 4 Linked List @@ -911,7 +828,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 #### Day 14 Stack @@ -940,7 +857,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 | 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 #### Day 4 Linked List @@ -972,7 +889,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 #### Day 9 Binary Search Tree @@ -1008,7 +925,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 | 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 #### Day 15 Tree @@ -1044,7 +961,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 | 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 ### Udemy @@ -1054,16 +971,16 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -| 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 56 | 95.68 -| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 137 | 88.64 +| 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 53 | 83.14 +| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 #### Udemy Strings | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 | 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 @@ -1071,7 +988,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 #### Udemy Arrays @@ -1080,7 +997,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 | 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 @@ -1093,7 +1010,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 #### Udemy Famous Algorithm @@ -1121,15 +1038,15 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 -| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 +| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 | 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 | 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 | 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 | 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 | 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 | 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 #### Udemy Tree Stack Queue @@ -1168,17 +1085,17 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 | 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 | 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 -| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 +| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 5 | 90.44 #### Udemy Backtracking/Recursion | | | | | | |-|-|-|-|-|- -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 | 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 | 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 #### Udemy Bit Manipulation @@ -1206,20 +1123,20 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 -| 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 64 | 95.38 +| 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 2 | 99.08 #### Top Interview 150 Two Pointers | | | | | | |-|-|-|-|-|- -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 #### Top Interview 150 Sliding Window | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 | 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 #### Top Interview 150 Matrix @@ -1234,7 +1151,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 92 | 93.69 #### Top Interview 150 Intervals @@ -1247,7 +1164,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 | 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 #### Top Interview 150 Linked List @@ -1255,11 +1172,11 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 92 | 77.86 -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 2 | 95.82 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 | 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 -| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 | 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 #### Top Interview 150 Binary Tree General @@ -1309,10 +1226,10 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 | 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 | 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 #### Top Interview 150 Divide and Conquer @@ -1320,7 +1237,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 -| 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 76 | 94.52 +| 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 4 | 97.65 #### Top Interview 150 Kadane's Algorithm @@ -1332,12 +1249,12 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -| 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Big_O_Time_O(log(min(N,M)))_Space_O(1), AI_can_be_used_to_solve_the_task | 86 | 92.15 +| 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Big_O_Time_O(log(min(N,M)))_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 82.74 #### Top Interview 150 Heap @@ -1356,7 +1273,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 137 | 88.64 +| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 #### Top Interview 150 1D DP @@ -1373,8 +1290,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 ### Data Structure I @@ -1389,7 +1306,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 #### Day 3 Array @@ -1418,7 +1335,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 #### Day 8 Linked List @@ -1430,7 +1347,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 #### Day 10 Tree @@ -1471,7 +1388,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 #### Day 2 Array @@ -1520,13 +1437,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 #### Day 10 Linked List | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 92 | 77.86 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 2 | 95.82 | 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 #### Day 11 Linked List @@ -1539,13 +1456,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 +| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 #### Day 13 Linked List | | | | | | |-|-|-|-|-|- -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 #### Day 14 Stack Queue @@ -1593,6 +1510,89 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +### Algorithm I + +#### Day 1 Binary Search + +| | | | | | +|-|-|-|-|-|- +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 + +#### Day 2 Two Pointers + +| | | | | | +|-|-|-|-|-|- +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 + +#### Day 3 Two Pointers + +| | | | | | +|-|-|-|-|-|- +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 + +#### Day 4 Two Pointers + +| | | | | | +|-|-|-|-|-|- + +#### Day 5 Two Pointers + +| | | | | | +|-|-|-|-|-|- +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 + +#### Day 6 Sliding Window + +| | | | | | +|-|-|-|-|-|- +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 + +#### Day 7 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- + +#### Day 8 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- + +#### Day 9 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- + +#### Day 10 Recursion Backtracking + +| | | | | | +|-|-|-|-|-|- +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 + +#### Day 11 Recursion Backtracking + +| | | | | | +|-|-|-|-|-|- +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 + +#### Day 12 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 + +#### Day 13 Bit Manipulation + +| | | | | | +|-|-|-|-|-|- + +#### Day 14 Bit Manipulation + +| | | | | | +|-|-|-|-|-|- +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 + ## Algorithms | # | Title | Difficulty | Tag | Time, ms | Time, % @@ -1661,7 +1661,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_2_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Data_Structure_I_Day_5_Array, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_8, Level_2_Day_8_Binary_Search, Udemy_2D_Arrays/Matrix, Top_Interview_150_Binary_Search, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 | 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 68 | 95.20 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_2, Level_1_Day_10_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 | 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_15, Level_1_Day_11_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 @@ -1675,32 +1675,32 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_4, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Dynamic_Programming_I_Day_9, Udemy_Two_Pointers, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 | 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Udemy_Arrays, Big_O_Time_O(n)_Space_O(n) | 55 | 98.51 -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Algorithm_II_Day_10_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 65 | 86.86 -| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_I_Day_1_Binary_Search, Binary_Search_I_Day_2, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 51 | 80.95 -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_5, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 45 | 98.05 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_11, Level_2_Day_8_Binary_Search, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 43 | 98.54 -| 0032 |[Longest Valid Parentheses](src/main/ts/g0001_0100/s0032_longest_valid_parentheses/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Stack, Big_O_Time_O(n)_Space_O(1) | 56 | 89.31 -| 0031 |[Next Permutation](src/main/ts/g0001_0100/s0031_next_permutation/solution.ts)| Medium | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 47 | 99.30 -| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_13_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(n)_Space_O(k) | 74 | 66.83 -| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_12_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 59 | 62.67 -| 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Top_Interview_150_Divide_and_Conquer, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 76 | 94.52 -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 60 | 62.03 -| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_7_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(m+n)_Space_O(m+n) | 59 | 86.77 -| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Data_Structure_I_Day_9_Stack_Queue, Udemy_Strings, Top_Interview_150_Stack, Big_O_Time_O(n)_Space_O(n) | 50 | 95.90 -| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Algorithm_I_Day_5_Two_Pointers, Level_2_Day_3_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(L)_Space_O(L) | 54 | 87.87 -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 52 | 79.11 -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_1_Array, Algorithm_II_Day_3_Two_Pointers, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 148 | 92.62 -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Algorithm_II_Day_4_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 57 | 98.23 -| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Udemy_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 69 | 92.65 -| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math, Udemy_Integers, Top_Interview_150_Math | 137 | 88.64 -| 0008 |[String to Integer (atoi)](src/main/ts/g0001_0100/s0008_string_to_integer_atoi/solution.ts)| Medium | Top_Interview_Questions, String | 56 | 99.01 -| 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math, Udemy_Integers | 56 | 95.68 -| 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String, Top_Interview_150_Array/String | 64 | 95.38 -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Data_Structure_II_Day_9_String, Algorithm_II_Day_14_Dynamic_Programming, Dynamic_Programming_I_Day_17, Udemy_Strings, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n)_Space_O(n) | 68 | 95.34 -| 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Top_Interview_150_Binary_Search, Big_O_Time_O(log(min(N,M)))_Space_O(1), AI_can_be_used_to_solve_the_task | 86 | 92.15 -| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Algorithm_I_Day_6_Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Udemy_Strings, Top_Interview_150_Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 65 | 90.77 -| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Data_Structure_II_Day_10_Linked_List, Programming_Skills_II_Day_15, Top_Interview_150_Linked_List, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 92 | 77.86 -| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Data_Structure_I_Day_2_Array, Level_1_Day_13_Hashmap, Udemy_Arrays, Top_Interview_150_Hashmap, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 54 | 91.72 +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Algorithm_II_Day_10_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 +| 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_I_Day_1_Binary_Search, Binary_Search_I_Day_2, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_5, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_11, Level_2_Day_8_Binary_Search, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0032 |[Longest Valid Parentheses](src/main/ts/g0001_0100/s0032_longest_valid_parentheses/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Stack, Big_O_Time_O(n)_Space_O(1) | 3 | 71.05 +| 0031 |[Next Permutation](src/main/ts/g0001_0100/s0031_next_permutation/solution.ts)| Medium | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_13_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 +| 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_12_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Top_Interview_150_Divide_and_Conquer, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 4 | 97.65 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 +| 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_7_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 +| 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Data_Structure_I_Day_9_Stack_Queue, Udemy_Strings, Top_Interview_150_Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 +| 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Algorithm_I_Day_5_Two_Pointers, Level_2_Day_3_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_1_Array, Algorithm_II_Day_3_Two_Pointers, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Algorithm_II_Day_4_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 +| 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Udemy_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 5 | 90.44 +| 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math, Udemy_Integers, Top_Interview_150_Math | 3 | 99.14 +| 0008 |[String to Integer (atoi)](src/main/ts/g0001_0100/s0008_string_to_integer_atoi/solution.ts)| Medium | Top_Interview_Questions, String | 1 | 90.14 +| 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math, Udemy_Integers | 53 | 83.14 +| 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String, Top_Interview_150_Array/String | 2 | 99.08 +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Data_Structure_II_Day_9_String, Algorithm_II_Day_14_Dynamic_Programming, Dynamic_Programming_I_Day_17, Udemy_Strings, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 +| 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Top_Interview_150_Binary_Search, Big_O_Time_O(log(min(N,M)))_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 82.74 +| 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Algorithm_I_Day_6_Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Udemy_Strings, Top_Interview_150_Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 +| 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Data_Structure_II_Day_10_Linked_List, Programming_Skills_II_Day_15, Top_Interview_150_Linked_List, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 2 | 95.82 +| 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Data_Structure_I_Day_2_Array, Level_1_Day_13_Hashmap, Udemy_Arrays, Top_Interview_150_Hashmap, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 ## Contributing Your ideas/fixes/algorithms are more than welcome! diff --git a/src/main/ts/g0001_0100/s0001_two_sum/solution.ts b/src/main/ts/g0001_0100/s0001_two_sum/solution.ts index e2a22d1..e344a0d 100644 --- a/src/main/ts/g0001_0100/s0001_two_sum/solution.ts +++ b/src/main/ts/g0001_0100/s0001_two_sum/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table // #Data_Structure_I_Day_2_Array #Level_1_Day_13_Hashmap #Udemy_Arrays #Top_Interview_150_Hashmap // #Big_O_Time_O(n)_Space_O(n) #AI_can_be_used_to_solve_the_task -// #2023_09_28_Time_54_ms_(91.72%)_Space_45.5_MB_(22.26%) +// #2025_03_22_Time_1_ms_(89.70%)_Space_59.39_MB_(8.75%) function twoSum(nums: number[], target: number): number[] { const indexMap: Map = new Map() diff --git a/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts b/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts index d07c69d..eee9f4e 100644 --- a/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts +++ b/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Math #Linked_List #Recursion // #Data_Structure_II_Day_10_Linked_List #Programming_Skills_II_Day_15 // #Top_Interview_150_Linked_List #Big_O_Time_O(max(N,M))_Space_O(max(N,M)) -// #AI_can_be_used_to_solve_the_task #2023_09_28_Time_92_ms_(77.86%)_Space_48_MB_(69.29%) +// #AI_can_be_used_to_solve_the_task #2025_03_22_Time_2_ms_(95.82%)_Space_62.80_MB_(21.07%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts b/src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts index 8e5d2ec..c5514eb 100644 --- a/src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts +++ b/src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Sliding_Window // #Algorithm_I_Day_6_Sliding_Window #Level_2_Day_14_Sliding_Window/Two_Pointer #Udemy_Strings // #Top_Interview_150_Sliding_Window #Big_O_Time_O(n)_Space_O(1) #AI_can_be_used_to_solve_the_task -// #2023_09_28_Time_65_ms_(90.77%)_Space_44.9_MB_(95.29%) +// #2025_03_22_Time_3_ms_(96.91%)_Space_59.12_MB_(43.55%) function lengthOfLongestSubstring(s: string): number { const lastIndices: number[] = new Array(256).fill(-1) diff --git a/src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts b/src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts index dfc3200..516e7f3 100644 --- a/src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts +++ b/src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search #Divide_and_Conquer // #Top_Interview_150_Binary_Search #Big_O_Time_O(log(min(N,M)))_Space_O(1) -// #AI_can_be_used_to_solve_the_task #2023_08_26_Time_86_ms_(92.15%)_Space_48.3_MB_(59.73%) +// #AI_can_be_used_to_solve_the_task #2025_03_22_Time_3_ms_(82.74%)_Space_59.34_MB_(44.01%) function findMedianSortedArrays(nums1: number[], nums2: number[]): number { const nums = nums1.concat(nums2) diff --git a/src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts b/src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts index a4f3964..6b12628 100644 --- a/src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts +++ b/src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming // #Data_Structure_II_Day_9_String #Algorithm_II_Day_14_Dynamic_Programming // #Dynamic_Programming_I_Day_17 #Udemy_Strings #Top_Interview_150_Multidimensional_DP -// #Big_O_Time_O(n)_Space_O(n) #2023_09_28_Time_68_ms_(95.34%)_Space_44.5_MB_(96.58%) +// #Big_O_Time_O(n)_Space_O(n) #2025_03_22_Time_8_ms_(99.14%)_Space_59.13_MB_(33.28%) function longestPalindrome(s: string): string { const newStr: string[] = new Array(s.length * 2 + 1) diff --git a/src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts b/src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts index f34e6ed..8e48ed8 100644 --- a/src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts +++ b/src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts @@ -1,5 +1,5 @@ // #Medium #String #Top_Interview_150_Array/String -// #2023_08_26_Time_64_ms_(95.38%)_Space_47.3_MB_(64.49%) +// #2025_03_22_Time_2_ms_(99.08%)_Space_60.88_MB_(31.04%) function convert(s: string, numRows: number): string { if (numRows < 2) { diff --git a/src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts b/src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts index 89e5463..a714b35 100644 --- a/src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts +++ b/src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_Interview_Questions #Math #Udemy_Integers -// #2023_08_25_Time_56_ms_(95.68%)_Space_43.8_MB_(99.70%) +// #2025_03_22_Time_53_ms_(83.14%)_Space_58.56_MB_(6.02%) function reverse(x: number): number { let remaining = Math.abs(x) diff --git a/src/main/ts/g0001_0100/s0008_string_to_integer_atoi/solution.ts b/src/main/ts/g0001_0100/s0008_string_to_integer_atoi/solution.ts index ceb4dcd..fd80851 100644 --- a/src/main/ts/g0001_0100/s0008_string_to_integer_atoi/solution.ts +++ b/src/main/ts/g0001_0100/s0008_string_to_integer_atoi/solution.ts @@ -1,4 +1,4 @@ -// #Medium #Top_Interview_Questions #String #2023_08_25_Time_56_ms_(99.01%)_Space_44_MB_(98.27%) +// #Medium #Top_Interview_Questions #String #2025_03_22_Time_1_ms_(90.14%)_Space_58.06_MB_(42.36%) function myAtoi(s: string): number { s = s.trim() diff --git a/src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts b/src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts index 2bab920..0d315e2 100644 --- a/src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts +++ b/src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts @@ -1,5 +1,5 @@ // #Easy #Math #Udemy_Integers #Top_Interview_150_Math -// #2023_08_25_Time_137_ms_(88.64%)_Space_50.5_MB_(99.43%) +// #2025_03_22_Time_3_ms_(99.14%)_Space_64.18_MB_(50.40%) function isPalindrome(x: number): boolean { if (x < 0) { diff --git a/src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts b/src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts index a98eff9..05cfa01 100644 --- a/src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts +++ b/src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts @@ -1,5 +1,5 @@ // #Hard #Top_Interview_Questions #String #Dynamic_Programming #Recursion #Udemy_Dynamic_Programming -// #Big_O_Time_O(m*n)_Space_O(m*n) #2023_08_25_Time_69_ms_(92.65%)_Space_45.9_MB_(50.61%) +// #Big_O_Time_O(m*n)_Space_O(m*n) #2025_03_22_Time_5_ms_(90.44%)_Space_59.10_MB_(22.68%) function isMatch(s: string, p: string): boolean { // NOSONAR const result = new Array(s.length + 1) diff --git a/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts b/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts index 684d7be..dca9c4c 100644 --- a/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts +++ b/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Greedy #Two_Pointers // #Algorithm_II_Day_4_Two_Pointers #Top_Interview_150_Two_Pointers #Big_O_Time_O(n)_Space_O(1) -// #2023_08_28_Time_57_ms_(98.23%)_Space_50.9_MB_(84.15%) +// #2025_03_22_Time_2_ms_(80.13%)_Space_65.63_MB_(10.65%) function maxArea(height: number[]): number { let maxArea = -1 diff --git a/src/main/ts/g0001_0100/s0015_3sum/solution.ts b/src/main/ts/g0001_0100/s0015_3sum/solution.ts index da7842f..e4ad9bd 100644 --- a/src/main/ts/g0001_0100/s0015_3sum/solution.ts +++ b/src/main/ts/g0001_0100/s0015_3sum/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting #Two_Pointers // #Data_Structure_II_Day_1_Array #Algorithm_II_Day_3_Two_Pointers #Udemy_Two_Pointers // #Top_Interview_150_Two_Pointers #Big_O_Time_O(n*log(n))_Space_O(n^2) -// #2023_08_28_Time_148_ms_(92.62%)_Space_59.1_MB_(70.24%) +// #2025_03_22_Time_30_ms_(91.56%)_Space_74.61_MB_(11.14%) function threeSum(nums: number[]): number[][] { //NOSONAR nums.sort((a, b) => a - b) diff --git a/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts b/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts index 9e0425e..32a7978 100644 --- a/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts +++ b/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Backtracking // #Algorithm_II_Day_11_Recursion_Backtracking #Udemy_Backtracking/Recursion // #Top_Interview_150_Backtracking #Big_O_Time_O(4^n)_Space_O(n) -// #2023_08_28_Time_52_ms_(79.11%)_Space_43.7_MB_(37.41%) +// #2025_03_22_Time_0_ms_(100.00%)_Space_56.27_MB_(8.55%) function letterCombinations(digits: string): string[] { if (digits.length === 0) { diff --git a/src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts b/src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts index c33ee8e..ce4f363 100644 --- a/src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts +++ b/src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Two_Pointers #Linked_List // #Algorithm_I_Day_5_Two_Pointers #Level_2_Day_3_Linked_List #Top_Interview_150_Linked_List -// #Big_O_Time_O(L)_Space_O(L) #2023_08_28_Time_54_ms_(87.87%)_Space_44.7_MB_(49.30%) +// #Big_O_Time_O(L)_Space_O(L) #2025_03_22_Time_0_ms_(100.00%)_Space_58.00_MB_(13.12%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts b/src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts index 9095bef..cdf4b2a 100644 --- a/src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts +++ b/src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #String #Stack // #Data_Structure_I_Day_9_Stack_Queue #Udemy_Strings #Top_Interview_150_Stack -// #Big_O_Time_O(n)_Space_O(n) #2023_08_28_Time_50_ms_(95.90%)_Space_43.5_MB_(83.27%) +// #Big_O_Time_O(n)_Space_O(n) #2025_03_22_Time_1_ms_(86.85%)_Space_59.18_MB_(9.27%) function isValid(s: string): boolean { const stack: string[] = [] diff --git a/src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts b/src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts index 7507f19..d2df408 100644 --- a/src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts +++ b/src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Linked_List #Recursion // #Data_Structure_I_Day_7_Linked_List #Algorithm_I_Day_10_Recursion_Backtracking // #Level_1_Day_3_Linked_List #Udemy_Linked_List #Top_Interview_150_Linked_List -// #Big_O_Time_O(m+n)_Space_O(m+n) #2023_08_29_Time_59_ms_(86.77%)_Space_44_MB_(98.03%) +// #Big_O_Time_O(m+n)_Space_O(m+n) #2025_03_22_Time_1_ms_(51.21%)_Space_59.28_MB_(6.60%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts b/src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts index 1e8dfe9..672ffd6 100644 --- a/src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts +++ b/src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming // #Backtracking #Algorithm_II_Day_11_Recursion_Backtracking #Udemy_Backtracking/Recursion // #Top_Interview_150_Backtracking #Big_O_Time_O(2^n)_Space_O(n) -// #2023_08_29_Time_60_ms_(62.03%)_Space_45.6_MB_(21.59%) +// #2025_03_22_Time_1_ms_(72.82%)_Space_56.97_MB_(44.53%) function generateParenthesis(n: number): string[] { const sb: string[] = [] diff --git a/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts b/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts index 324c0f4..13212d9 100644 --- a/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts +++ b/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Heap_Priority_Queue #Linked_List // #Divide_and_Conquer #Merge_Sort #Top_Interview_150_Divide_and_Conquer -// #Big_O_Time_O(k*n*log(k))_Space_O(log(k)) #2023_10_09_Time_76_ms_(94.52%)_Space_47.9_MB_(84.35%) +// #Big_O_Time_O(k*n*log(k))_Space_O(log(k)) #2025_03_22_Time_4_ms_(97.65%)_Space_64.08_MB_(30.06%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts b/src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts index 71f3454..959f448 100644 --- a/src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts +++ b/src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Linked_List #Recursion #Data_Structure_II_Day_12_Linked_List // #Udemy_Linked_List #Big_O_Time_O(n)_Space_O(1) -// #2023_08_29_Time_59_ms_(62.67%)_Space_44.7_MB_(26.03%) +// #2025_03_22_Time_0_ms_(100.00%)_Space_56.52_MB_(6.71%) /** * Definition for singly-linked list. diff --git a/src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts b/src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts index f42aff4..79a44ad 100644 --- a/src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts +++ b/src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Linked_List #Recursion #Data_Structure_II_Day_13_Linked_List // #Udemy_Linked_List #Top_Interview_150_Linked_List #Big_O_Time_O(n)_Space_O(k) -// #2023_08_29_Time_74_ms_(66.83%)_Space_46.1_MB_(94.47%) +// #2025_03_22_Time_0_ms_(100.00%)_Space_60.66_MB_(27.50%) /** * Definition for singly-linked list. diff --git a/src/main/ts/g0001_0100/s0031_next_permutation/solution.ts b/src/main/ts/g0001_0100/s0031_next_permutation/solution.ts index 966dff2..ca349e0 100644 --- a/src/main/ts/g0001_0100/s0031_next_permutation/solution.ts +++ b/src/main/ts/g0001_0100/s0031_next_permutation/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Array #Two_Pointers #Big_O_Time_O(n)_Space_O(1) -// #2023_09_26_Time_47_ms_(99.30%)_Space_45_MB_(20.98%) +// #2025_03_22_Time_0_ms_(100.00%)_Space_58.80_MB_(7.83%) /* Do not return anything, modify nums in-place instead. diff --git a/src/main/ts/g0001_0100/s0032_longest_valid_parentheses/solution.ts b/src/main/ts/g0001_0100/s0032_longest_valid_parentheses/solution.ts index 69b2a24..d210153 100644 --- a/src/main/ts/g0001_0100/s0032_longest_valid_parentheses/solution.ts +++ b/src/main/ts/g0001_0100/s0032_longest_valid_parentheses/solution.ts @@ -1,5 +1,5 @@ // #Hard #Top_100_Liked_Questions #String #Dynamic_Programming #Stack #Big_O_Time_O(n)_Space_O(1) -// #2023_09_26_Time_56_ms_(89.31%)_Space_43.9_MB_(100.00%) +// #2025_03_22_Time_3_ms_(71.05%)_Space_58.66_MB_(24.21%) function longestValidParentheses(s: string): number { let open = 0 diff --git a/src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts b/src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts index 79849e7..d2234e1 100644 --- a/src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts +++ b/src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search // #Algorithm_II_Day_1_Binary_Search #Binary_Search_I_Day_11 #Level_2_Day_8_Binary_Search // #Udemy_Binary_Search #Top_Interview_150_Binary_Search #Big_O_Time_O(log_n)_Space_O(1) -// #2023_09_27_Time_43_ms_(98.54%)_Space_44.3_MB_(31.85%) +// #2025_03_22_Time_0_ms_(100.00%)_Space_56.20_MB_(19.74%) function search(nums: number[], target: number): number { //NOSONAR let lowEnd: number = 0 diff --git a/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts b/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts index c0d2498..11c348d 100644 --- a/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts +++ b/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search // #Algorithm_II_Day_1_Binary_Search #Binary_Search_I_Day_5 #Top_Interview_150_Binary_Search -// #Big_O_Time_O(log_n)_Space_O(1) #2023_09_27_Time_45_ms_(98.05%)_Space_44.5_MB_(54.86%) +// #Big_O_Time_O(log_n)_Space_O(1) #2025_03_22_Time_0_ms_(100.00%)_Space_57.18_MB_(12.18%) function searchRange(nums: number[], target: number): number[] { //NOSONAR let first = -1 diff --git a/src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts b/src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts index 094452a..f1ec235 100644 --- a/src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts +++ b/src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Array #Binary_Search #Algorithm_I_Day_1_Binary_Search // #Binary_Search_I_Day_2 #Top_Interview_150_Binary_Search #Big_O_Time_O(log_n)_Space_O(1) -// #2023_09_27_Time_51_ms_(80.95%)_Space_44.6_MB_(16.67%) +// #2025_03_22_Time_0_ms_(100.00%)_Space_56.30_MB_(12.51%) function searchInsert(nums: number[], target: number): number { let left = 0 diff --git a/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts b/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts index e744ced..0b8c183 100644 --- a/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts +++ b/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Array #Backtracking #Algorithm_II_Day_10_Recursion_Backtracking // #Level_2_Day_20_Brute_Force/Backtracking #Udemy_Backtracking/Recursion // #Top_Interview_150_Backtracking #Big_O_Time_O(2^n)_Space_O(n+2^n) -// #2023_09_29_Time_65_ms_(86.86%)_Space_45.8_MB_(75.98%) +// #2025_03_22_Time_1_ms_(98.17%)_Space_61.61_MB_(21.40%) function combinationSum(candidates: number[], target: number): number[][] { const result: number[][] = [] From bee194ffd68b3b6a500aca313943d87a51f2d2de Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sun, 23 Mar 2025 10:45:18 +0200 Subject: [PATCH 13/49] Improved tasks 41-102 --- README.md | 204 +++++++++--------- .../s0041_first_missing_positive/solution.ts | 2 +- .../s0042_trapping_rain_water/solution.ts | 2 +- .../g0001_0100/s0045_jump_game_ii/solution.ts | 45 ++-- .../g0001_0100/s0046_permutations/solution.ts | 2 +- .../g0001_0100/s0048_rotate_image/solution.ts | 2 +- .../s0049_group_anagrams/solution.ts | 2 +- .../ts/g0001_0100/s0051_n_queens/solution.ts | 2 +- .../s0053_maximum_subarray/solution.ts | 2 +- .../ts/g0001_0100/s0055_jump_game/solution.ts | 2 +- .../s0056_merge_intervals/solution.ts | 2 +- .../g0001_0100/s0062_unique_paths/solution.ts | 17 +- .../s0064_minimum_path_sum/solution.ts | 2 +- .../s0070_climbing_stairs/solution.ts | 2 +- .../s0072_edit_distance/solution.ts | 2 +- .../s0073_set_matrix_zeroes/solution.ts | 2 +- .../s0074_search_a_2d_matrix/solution.ts | 2 +- .../g0001_0100/s0075_sort_colors/solution.ts | 2 +- .../solution.ts | 2 +- .../ts/g0001_0100/s0078_subsets/solution.ts | 4 +- .../g0001_0100/s0079_word_search/solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../s0101_symmetric_tree/solution.ts | 2 +- .../solution.ts | 2 +- 27 files changed, 148 insertions(+), 168 deletions(-) diff --git a/README.md b/README.md index 8e28190..52c6915 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 #### Day 2 Binary Search @@ -82,7 +82,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 +| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 #### Day 10 Recursion Backtracking @@ -96,20 +96,20 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 | 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 -| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 +| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 243 | 85.30 #### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 #### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 #### Day 14 Dynamic Programming @@ -139,7 +139,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 #### Day 19 Bit Manipulation @@ -200,7 +200,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 #### Day 9 @@ -340,7 +340,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 3 @@ -352,14 +352,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 #### Day 5 | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 #### Day 6 @@ -383,7 +383,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 #### Day 10 @@ -394,7 +394,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 +| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 #### Day 12 @@ -415,13 +415,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 #### Day 16 | | | | | | |-|-|-|-|-|- -| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 #### Day 17 @@ -441,7 +441,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 #### Day 20 @@ -555,7 +555,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 #### Day 8 @@ -576,7 +576,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 #### Day 12 @@ -787,7 +787,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 #### Day 7 Binary Search @@ -798,7 +798,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 #### Day 9 Graph/BFS/DFS @@ -810,13 +810,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 11 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 #### Day 12 Sliding Window/Two Pointer @@ -888,7 +888,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 #### Day 9 Binary Search Tree @@ -926,13 +926,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 -| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 +| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 20 | 90.35 #### Day 15 Tree | | | | | | |-|-|-|-|-|- -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 #### Day 16 Design @@ -945,7 +945,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 #### Day 18 Stack @@ -962,7 +962,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 ### Udemy @@ -982,7 +982,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 | 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 #### Udemy Binary Search @@ -999,24 +999,24 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 55 | 98.51 +| 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 1 | 99.11 | 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 #### Udemy Two Pointers | | | | | | |-|-|-|-|-|- -| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 #### Udemy Famous Algorithm | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 #### Udemy Sorting Algorithms @@ -1028,10 +1028,10 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 +| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 4 | 50.63 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 #### Udemy Linked List @@ -1053,13 +1053,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 #### Udemy Trie and Heap @@ -1081,11 +1081,11 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 | 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 | 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 5 | 90.44 #### Udemy Backtracking/Recursion @@ -1094,9 +1094,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 -| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 +| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 | 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 #### Udemy Bit Manipulation @@ -1119,10 +1119,10 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 2 | 99.08 #### Top Interview 150 Two Pointers @@ -1137,20 +1137,20 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 -| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 +| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 20 | 90.35 #### Top Interview 150 Matrix | | | | | | |-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 +| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 4 | 50.63 #### Top Interview 150 Hashmap | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 92 | 93.69 @@ -1158,7 +1158,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 #### Top Interview 150 Stack @@ -1185,7 +1185,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 @@ -1195,14 +1195,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 #### Top Interview 150 Binary Search Tree | | | | | | |-|-|-|-|-|- | 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 #### Top Interview 150 Graph General @@ -1227,10 +1227,10 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 | 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 -| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 +| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 243 | 85.30 #### Top Interview 150 Divide and Conquer @@ -1243,14 +1243,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 #### Top Interview 150 Binary Search | | | | | | |-|-|-|-|-|- | 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 @@ -1279,7 +1279,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 @@ -1289,9 +1289,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 ### Data Structure I @@ -1300,7 +1300,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 #### Day 2 Array @@ -1323,7 +1323,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 #### Day 6 String @@ -1353,15 +1353,15 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 +| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 11 Tree | | | | | | |-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 #### Day 12 Tree @@ -1378,7 +1378,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 ### Data Structure II @@ -1394,14 +1394,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 +| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 #### Day 3 Array | | | | | | |-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 #### Day 4 Array @@ -1431,7 +1431,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 #### Day 9 String @@ -1573,13 +1573,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 #### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 #### Day 13 Bit Manipulation @@ -1649,32 +1649,32 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Udemy_Linked_List, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Programming_Skills_I_Day_10_Linked_List_and_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_1_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS, Big_O_Time_O(N)_Space_O(N) | 60 | 97.47 -| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(log(N)) | 49 | 98.54 -| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_I_Day_14_Tree, Level_1_Day_8_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 51 | 98.35 -| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Dynamic_Programming_I_Day_11, Big_O_Time_O(n)_Space_O(1) | 45 | 96.00 -| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Data_Structure_I_Day_10_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 45 | 97.30 -| 0084 |[Largest Rectangle in Histogram](src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n_log_n)_Space_O(log_n) | 78 | 92.44 -| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Top_Interview_150_Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 327 | 95.78 -| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Algorithm_II_Day_9_Recursion_Backtracking, Udemy_Backtracking/Recursion, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 50 | 94.61 -| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Top_Interview_150_Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 82 | 82.17 -| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_2_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 43 | 97.41 -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Data_Structure_I_Day_5_Array, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_8, Level_2_Day_8_Binary_Search, Udemy_2D_Arrays/Matrix, Top_Interview_150_Binary_Search, Big_O_Time_O(endRow+endCol)_Space_O(1) | 45 | 96.82 -| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 61 | 97.66 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 9 | 93.59 -| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_2, Level_1_Day_10_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 44 | 94.58 -| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 48 | 99.67 -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_15, Level_1_Day_11_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 40 | 98.97 -| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Data_Structure_II_Day_2_Array, Level_2_Day_17_Interval, Udemy_2D_Arrays/Matrix, Top_Interview_150_Intervals, Big_O_Time_O(n_log_n)_Space_O(n) | 84 | 92.06 -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_4, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 58 | 91.95 -| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Data_Structure_I_Day_1_Array, Dynamic_Programming_I_Day_5, Udemy_Famous_Algorithm, Top_Interview_150_Kadane's_Algorithm, Big_O_Time_O(n)_Space_O(1) | 66 | 90.36 -| 0051 |[N-Queens](src/main/ts/g0001_0100/s0051_n_queens/solution.ts)| Hard | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(N!)_Space_O(N) | 57 | 93.84 -| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Data_Structure_II_Day_8_String, Programming_Skills_II_Day_11, Udemy_Strings, Top_Interview_150_Hashmap, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 93 | 97.29 -| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Data_Structure_II_Day_3_Array, Programming_Skills_II_Day_7, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(n^2)_Space_O(1) | 45 | 95.31 -| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Algorithm_I_Day_11_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 56 | 96.26 -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_4, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 50 | 95.93 -| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Dynamic_Programming_I_Day_9, Udemy_Two_Pointers, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 46 | 99.52 -| 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Udemy_Arrays, Big_O_Time_O(n)_Space_O(n) | 55 | 98.51 +| 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_1_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_I_Day_14_Tree, Level_1_Day_8_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Dynamic_Programming_I_Day_11, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Data_Structure_I_Day_10_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0084 |[Largest Rectangle in Histogram](src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n_log_n)_Space_O(log_n) | 15 | 72.81 +| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Top_Interview_150_Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 243 | 85.30 +| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Algorithm_II_Day_9_Recursion_Backtracking, Udemy_Backtracking/Recursion, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 +| 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Top_Interview_150_Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 20 | 90.35 +| 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_2_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Data_Structure_I_Day_5_Array, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_8, Level_2_Day_8_Binary_Search, Udemy_2D_Arrays/Matrix, Top_Interview_150_Binary_Search, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 4 | 50.63 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 +| 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_2, Level_1_Day_10_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_15, Level_1_Day_11_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Data_Structure_II_Day_2_Array, Level_2_Day_17_Interval, Udemy_2D_Arrays/Matrix, Top_Interview_150_Intervals, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_4, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Data_Structure_I_Day_1_Array, Dynamic_Programming_I_Day_5, Udemy_Famous_Algorithm, Top_Interview_150_Kadane's_Algorithm, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0051 |[N-Queens](src/main/ts/g0001_0100/s0051_n_queens/solution.ts)| Hard | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(N!)_Space_O(N) | 6 | 95.85 +| 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Data_Structure_II_Day_8_String, Programming_Skills_II_Day_11, Udemy_Strings, Top_Interview_150_Hashmap, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 +| 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Data_Structure_II_Day_3_Array, Programming_Skills_II_Day_7, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 +| 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Algorithm_I_Day_11_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_4, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 +| 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Dynamic_Programming_I_Day_9, Udemy_Two_Pointers, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Udemy_Arrays, Big_O_Time_O(n)_Space_O(n) | 1 | 99.11 | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Algorithm_II_Day_10_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 | 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_I_Day_1_Binary_Search, Binary_Search_I_Day_2, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_5, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 diff --git a/src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts b/src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts index c2965b2..2b742a7 100644 --- a/src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts +++ b/src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts @@ -1,5 +1,5 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Udemy_Arrays -// #Big_O_Time_O(n)_Space_O(n) #2023_09_29_Time_55_ms_(98.51%)_Space_49.8_MB_(60.20%) +// #Big_O_Time_O(n)_Space_O(n) #2025_03_23_Time_1_ms_(99.11%)_Space_65.96_MB_(40.18%) function firstMissingPositive(nums: number[]): number { let i = 0 diff --git a/src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts b/src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts index 4793367..5f5e5c0 100644 --- a/src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts +++ b/src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts @@ -1,7 +1,7 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming #Two_Pointers // #Stack #Monotonic_Stack #Dynamic_Programming_I_Day_9 #Udemy_Two_Pointers // #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(1) -// #2023_09_30_Time_46_ms_(99.52%)_Space_44.4_MB_(97.58%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_57.78_MB_(55.13%) function trap(height: number[]): number { let result = 0 diff --git a/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts b/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts index 38c6277..800e710 100644 --- a/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts +++ b/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts @@ -1,42 +1,23 @@ // #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Greedy // #Algorithm_II_Day_13_Dynamic_Programming #Dynamic_Programming_I_Day_4 // #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(1) -// #2023_09_30_Time_50_ms_(95.93%)_Space_44.9_MB_(65.88%) +// #2025_03_23_Time_1_ms_(84.27%)_Space_58.46_MB_(28.93%) -function jump(nums: number[]): number { //NOSONAR - let minJmp = new Array(nums.length) - if (nums.length === 1) return 0 - let prevIndex = 0 - minJmp[prevIndex] = 0 - while (prevIndex < nums.length - 1) { - let nextMaxJmpTo = nums[prevIndex] + prevIndex - let prevIndexJmp = minJmp[prevIndex] +function jump(nums: number[]): number { + let minJump = 0, + farthest = 0, + currentEnd = 0 + for (let i = 0; i < nums.length - 1; i++) { + farthest = Math.max(farthest, i + nums[i]) + // If we've reached the end of the current jump range + if (i === currentEnd) { + minJump++ + currentEnd = farthest - let farthestJumpVal = -1 - let farthestJumpIndex = -1 - for (let i = nextMaxJmpTo; ; i--) { - if (i >= nums.length) { - continue - } - if (i === nums.length - 1) { - return prevIndexJmp + 1 - } - if (minJmp[i] != undefined) { - break - } - minJmp[i] = prevIndexJmp + 1 - let curmaxTo = nums[i] + i - if (farthestJumpVal < curmaxTo) { - farthestJumpVal = curmaxTo - farthestJumpIndex = i - } + if (currentEnd >= nums.length - 1) break } - if (farthestJumpIndex === -1) { - return -1 - } - prevIndex = farthestJumpIndex } - return minJmp[nums.length - 1] + return minJump } export { jump } diff --git a/src/main/ts/g0001_0100/s0046_permutations/solution.ts b/src/main/ts/g0001_0100/s0046_permutations/solution.ts index 66ae2fc..2cef51a 100644 --- a/src/main/ts/g0001_0100/s0046_permutations/solution.ts +++ b/src/main/ts/g0001_0100/s0046_permutations/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Backtracking // #Algorithm_I_Day_11_Recursion_Backtracking #Level_2_Day_20_Brute_Force/Backtracking // #Udemy_Backtracking/Recursion #Top_Interview_150_Backtracking #Big_O_Time_O(n*n!)_Space_O(n+n!) -// #2023_09_30_Time_56_ms_(96.26%)_Space_45.7_MB_(55.35%) +// #2025_03_23_Time_1_ms_(84.44%)_Space_60.84_MB_(26.93%) function permute(nums: number[]): number[][] { const result: number[][] = [] diff --git a/src/main/ts/g0001_0100/s0048_rotate_image/solution.ts b/src/main/ts/g0001_0100/s0048_rotate_image/solution.ts index 77241b2..7f7feac 100644 --- a/src/main/ts/g0001_0100/s0048_rotate_image/solution.ts +++ b/src/main/ts/g0001_0100/s0048_rotate_image/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Math #Matrix // #Data_Structure_II_Day_3_Array #Programming_Skills_II_Day_7 #Udemy_2D_Arrays/Matrix // #Top_Interview_150_Matrix #Big_O_Time_O(n^2)_Space_O(1) -// #2023_09_30_Time_45_ms_(95.31%)_Space_44.4_MB_(48.24%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_57.37_MB_(17.79%) /* Do not return anything, modify matrix in-place instead. diff --git a/src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts b/src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts index c05a6db..8df43fb 100644 --- a/src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts +++ b/src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #String #Hash_Table #Sorting // #Data_Structure_II_Day_8_String #Programming_Skills_II_Day_11 #Udemy_Strings // #Top_Interview_150_Hashmap #Big_O_Time_O(n*k_log_k)_Space_O(n) -// #2023_09_30_Time_93_ms_(97.29%)_Space_52_MB_(99.08%) +// #2025_03_23_Time_27_ms_(78.99%)_Space_68.93_MB_(28.40%) function groupAnagrams(strs: string[]): string[][] { if (strs.length === 1) return [strs] diff --git a/src/main/ts/g0001_0100/s0051_n_queens/solution.ts b/src/main/ts/g0001_0100/s0051_n_queens/solution.ts index 1d423f3..e89d7fe 100644 --- a/src/main/ts/g0001_0100/s0051_n_queens/solution.ts +++ b/src/main/ts/g0001_0100/s0051_n_queens/solution.ts @@ -1,5 +1,5 @@ // #Hard #Top_100_Liked_Questions #Array #Backtracking #Big_O_Time_O(N!)_Space_O(N) -// #2023_09_30_Time_57_ms_(93.84%)_Space_45_MB_(83.56%) +// #2025_03_23_Time_6_ms_(95.85%)_Space_59.90_MB_(33.61%) function solveNQueens(n: number): string[][] { const result: string[][] = [] diff --git a/src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts b/src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts index e301fea..1ab9566 100644 --- a/src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts +++ b/src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming // #Divide_and_Conquer #Data_Structure_I_Day_1_Array #Dynamic_Programming_I_Day_5 // #Udemy_Famous_Algorithm #Top_Interview_150_Kadane's_Algorithm #Big_O_Time_O(n)_Space_O(1) -// #2023_09_30_Time_66_ms_(90.36%)_Space_51.9_MB_(80.92%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_65.50_MB_(44.96%) function maxSubArray(nums: number[]): number { let curSum: number = nums[0] diff --git a/src/main/ts/g0001_0100/s0055_jump_game/solution.ts b/src/main/ts/g0001_0100/s0055_jump_game/solution.ts index c4b5936..c38b2fa 100644 --- a/src/main/ts/g0001_0100/s0055_jump_game/solution.ts +++ b/src/main/ts/g0001_0100/s0055_jump_game/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming #Greedy // #Algorithm_II_Day_12_Dynamic_Programming #Dynamic_Programming_I_Day_4 #Udemy_Arrays // #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(1) -// #2023_09_30_Time_58_ms_(91.95%)_Space_47.4_MB_(70.79%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_59.92_MB_(51.18%) function canJump(nums: number[]): boolean { let availableSteps = nums[0] diff --git a/src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts b/src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts index d285a67..7d4e91b 100644 --- a/src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts +++ b/src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting // #Data_Structure_II_Day_2_Array #Level_2_Day_17_Interval #Udemy_2D_Arrays/Matrix // #Top_Interview_150_Intervals #Big_O_Time_O(n_log_n)_Space_O(n) -// #2023_10_01_Time_84_ms_(92.06%)_Space_49.9_MB_(69.16%) +// #2025_03_23_Time_7_ms_(87.99%)_Space_66.00_MB_(36.16%) function merge(intervals: number[][]): number[][] { let result = [] diff --git a/src/main/ts/g0001_0100/s0062_unique_paths/solution.ts b/src/main/ts/g0001_0100/s0062_unique_paths/solution.ts index 241091f..3d650eb 100644 --- a/src/main/ts/g0001_0100/s0062_unique_paths/solution.ts +++ b/src/main/ts/g0001_0100/s0062_unique_paths/solution.ts @@ -1,19 +1,18 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Dynamic_Programming #Math // #Combinatorics #Algorithm_II_Day_13_Dynamic_Programming #Dynamic_Programming_I_Day_15 // #Level_1_Day_11_Dynamic_Programming #Big_O_Time_O(m*n)_Space_O(m*n) -// #2023_10_01_Time_40_ms_(98.97%)_Space_42.8_MB_(72.52%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_55.15_MB_(43.54%) function uniquePaths(m: number, n: number): number { - const factorialize = (x: number) => { - if (x <= 1) return 1 - let res = x - while (x > 1) { - x-- - res *= x + let aboveRow = Array(n).fill(1) + for (let row = 1; row < m; row++) { + let currentRow = Array(n).fill(1) + for (let col = 1; col < n; col++) { + currentRow[col] = currentRow[col - 1] + aboveRow[col] } - return res + aboveRow = currentRow } - return factorialize(m + n - 2) / factorialize(m - 1) / factorialize(n - 1) + return aboveRow[n - 1] } export { uniquePaths } diff --git a/src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts b/src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts index 7fc57a2..82b84c8 100644 --- a/src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts +++ b/src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Matrix // #Dynamic_Programming_I_Day_16 #Udemy_Dynamic_Programming #Top_Interview_150_Multidimensional_DP -// #Big_O_Time_O(m*n)_Space_O(m*n) #2023_10_01_Time_48_ms_(99.67%)_Space_44.5_MB_(90.16%) +// #Big_O_Time_O(m*n)_Space_O(m*n) #2025_03_23_Time_4_ms_(70.73%)_Space_59.31_MB_(26.29%) function minPathSum(grid: number[][]): number { let [m, n] = [grid.length, grid[0].length] diff --git a/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts b/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts index 3746b9b..c6110a2 100644 --- a/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts +++ b/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Dynamic_Programming #Math #Memoization // #Algorithm_I_Day_12_Dynamic_Programming #Dynamic_Programming_I_Day_2 // #Level_1_Day_10_Dynamic_Programming #Udemy_Dynamic_Programming #Top_Interview_150_1D_DP -// #Big_O_Time_O(n)_Space_O(n) #2023_10_01_Time_44_ms_(94.58%)_Space_42.4_MB_(73.09%) +// #Big_O_Time_O(n)_Space_O(n) #2025_03_23_Time_0_ms_(100.00%)_Space_56.23_MB_(5.15%) function climbStairs(n: number, memo: Record = {}): number { if (n in memo) return memo[n] diff --git a/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts b/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts index 60c42f8..d4d3d49 100644 --- a/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts +++ b/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #String #Dynamic_Programming // #Algorithm_II_Day_18_Dynamic_Programming #Dynamic_Programming_I_Day_19 // #Udemy_Dynamic_Programming #Top_Interview_150_Multidimensional_DP #Big_O_Time_O(n^2)_Space_O(n2) -// #2025_02_15_Time_9_ms_(93.59%)_Space_57.68_MB_(49.82%) +// #2025_03_23_Time_6_ms_(93.83%)_Space_61.09_MB_(45.68%) function minDistance(word1: string, word2: string): number { const memo: number[][] = new Array(word1.length + 1).fill(0).map((_) => []) diff --git a/src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts b/src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts index 896c853..dde26bb 100644 --- a/src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts +++ b/src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Matrix // #Udemy_2D_Arrays/Matrix #Top_Interview_150_Matrix #Big_O_Time_O(m*n)_Space_O(1) -// #2023_10_01_Time_61_ms_(97.66%)_Space_45.9_MB_(30.73%) +// #2025_03_23_Time_4_ms_(50.63%)_Space_61.42_MB_(6.15%) /* Do not return anything, modify matrix in-place instead. diff --git a/src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts b/src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts index 738defb..3e684a7 100644 --- a/src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts +++ b/src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Array #Binary_Search #Matrix #Data_Structure_I_Day_5_Array // #Algorithm_II_Day_1_Binary_Search #Binary_Search_I_Day_8 #Level_2_Day_8_Binary_Search // #Udemy_2D_Arrays/Matrix #Top_Interview_150_Binary_Search #Big_O_Time_O(endRow+endCol)_Space_O(1) -// #2023_10_01_Time_45_ms_(96.82%)_Space_44.3_MB_(43.77%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_54.50_MB_(46.86%) function searchMatrix(matrix: number[][], target: number): boolean { const [m, n] = [matrix.length, matrix[0].length] diff --git a/src/main/ts/g0001_0100/s0075_sort_colors/solution.ts b/src/main/ts/g0001_0100/s0075_sort_colors/solution.ts index 5e3173e..deadd9f 100644 --- a/src/main/ts/g0001_0100/s0075_sort_colors/solution.ts +++ b/src/main/ts/g0001_0100/s0075_sort_colors/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting #Two_Pointers // #Data_Structure_II_Day_2_Array #Udemy_Arrays #Big_O_Time_O(n)_Space_O(1) -// #2023_10_02_Time_43_ms_(97.41%)_Space_42.5_MB_(85.34%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_56.04_MB_(26.80%) const sortColors = (nums: number[]) => { let i = 0 diff --git a/src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts b/src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts index 21b87ea..c069ae1 100644 --- a/src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts +++ b/src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Sliding_Window // #Level_2_Day_14_Sliding_Window/Two_Pointer #Top_Interview_150_Sliding_Window -// #Big_O_Time_O(s.length())_Space_O(1) #2023_10_02_Time_82_ms_(82.17%)_Space_46.2_MB_(81.89%) +// #Big_O_Time_O(s.length())_Space_O(1) #2025_03_23_Time_20_ms_(90.35%)_Space_58.72_MB_(57.91%) function minWindow(s: string, t: string): string { //NOSONAR const map: Map = new Map() diff --git a/src/main/ts/g0001_0100/s0078_subsets/solution.ts b/src/main/ts/g0001_0100/s0078_subsets/solution.ts index 3971504..8e55897 100644 --- a/src/main/ts/g0001_0100/s0078_subsets/solution.ts +++ b/src/main/ts/g0001_0100/s0078_subsets/solution.ts @@ -1,8 +1,8 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Bit_Manipulation #Backtracking // #Algorithm_II_Day_9_Recursion_Backtracking #Udemy_Backtracking/Recursion -// #Big_O_Time_O(2^n)_Space_O(n*2^n) #2023_10_02_Time_50_ms_(94.61%)_Space_44.8_MB_(75.83%) +// #Big_O_Time_O(2^n)_Space_O(n*2^n) #2025_03_23_Time_0_ms_(100.00%)_Space_58.49_MB_(41.68%) -const subsets = (nums: number[]): number[][] => { +function subsets(nums: number[]): number[][] { const sets: number[][] = [[]] for (const num of nums) sets.push(...sets.map((set) => [...set, num])) return sets diff --git a/src/main/ts/g0001_0100/s0079_word_search/solution.ts b/src/main/ts/g0001_0100/s0079_word_search/solution.ts index ffcd5ff..f06c1a9 100644 --- a/src/main/ts/g0001_0100/s0079_word_search/solution.ts +++ b/src/main/ts/g0001_0100/s0079_word_search/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Matrix #Backtracking // #Algorithm_II_Day_11_Recursion_Backtracking #Top_Interview_150_Backtracking -// #Big_O_Time_O(4^(m*n))_Space_O(m*n) #2023_10_03_Time_327_ms_(95.78%)_Space_43.4_MB_(84.98%) +// #Big_O_Time_O(4^(m*n))_Space_O(m*n) #2025_03_23_Time_243_ms_(85.30%)_Space_56.58_MB_(58.26%) function exist(board: string[][], word: string): boolean { if (word.length === 0) return false diff --git a/src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts b/src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts index 9b6c671..634843d 100644 --- a/src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts +++ b/src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts @@ -1,5 +1,5 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Stack #Monotonic_Stack -// #Big_O_Time_O(n_log_n)_Space_O(log_n) #2023_10_03_Time_78_ms_(92.44%)_Space_56.8_MB_(85.29%) +// #Big_O_Time_O(n_log_n)_Space_O(log_n) #2025_03_23_Time_15_ms_(72.81%)_Space_72.66_MB_(37.28%) function largestRectangleArea(heights: number[]): number { let stack = [] diff --git a/src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts b/src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts index 6bf7b20..f0b4f6e 100644 --- a/src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts +++ b/src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Tree #Binary_Tree // #Stack #Data_Structure_I_Day_10_Tree #Udemy_Tree_Stack_Queue #Big_O_Time_O(n)_Space_O(n) -// #2023_10_03_Time_45_ms_(97.30%)_Space_42.9_MB_(96.73%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_54.69_MB_(46.13%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts b/src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts index d080f77..39753dc 100644 --- a/src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts +++ b/src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts @@ -1,6 +1,6 @@ // #Medium #Dynamic_Programming #Math #Tree #Binary_Tree #Binary_Search_Tree // #Dynamic_Programming_I_Day_11 #Big_O_Time_O(n)_Space_O(1) -// #2023_10_03_Time_45_ms_(96.00%)_Space_42.9_MB_(25.33%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_55.21_MB_(33.33%) function numTrees(n: number): number { const uniqueCount = new Array(n + 1).fill(0) diff --git a/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts b/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts index 4ad9c1a..13cca78 100644 --- a/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts +++ b/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Tree #Binary_Tree // #Binary_Search_Tree #Data_Structure_I_Day_14_Tree #Level_1_Day_8_Binary_Search_Tree // #Udemy_Tree_Stack_Queue #Top_Interview_150_Binary_Search_Tree #Big_O_Time_O(N)_Space_O(log(N)) -// #2023_10_03_Time_51_ms_(98.35%)_Space_47.3_MB_(61.68%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_60.76_MB_(21.74%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts b/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts index 32242f0..830ea3a 100644 --- a/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts +++ b/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Breadth_First_Search // #Tree #Binary_Tree #Data_Structure_I_Day_11_Tree #Level_2_Day_15_Tree // #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(N)_Space_O(log(N)) -// #2023_10_04_Time_49_ms_(98.54%)_Space_45_MB_(59.02%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_58.35_MB_(25.66%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts b/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts index 257f624..1764202 100644 --- a/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts +++ b/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Breadth_First_Search #Tree // #Binary_Tree #Data_Structure_I_Day_11_Tree #Level_1_Day_6_Tree #Udemy_Tree_Stack_Queue // #Top_Interview_150_Binary_Tree_BFS #Big_O_Time_O(N)_Space_O(N) -// #2023_10_04_Time_60_ms_(97.47%)_Space_47_MB_(77.89%) +// #2025_03_23_Time_0_ms_(100.00%)_Space_59.70_MB_(51.83%) import { TreeNode } from '../../com_github_leetcode/treenode' From acd6215433583abec10dc6bf8287e4245d6f97d1 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Wed, 26 Mar 2025 05:45:59 +0200 Subject: [PATCH 14/49] Improved tasks 104-215 --- README.md | 206 +++++++++--------- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 23 +- .../s0131_palindrome_partitioning/solution.ts | 2 +- .../s0136_single_number/solution.ts | 2 +- .../solution.ts | 2 +- .../g0101_0200/s0139_word_break/solution.ts | 2 +- .../s0141_linked_list_cycle/solution.ts | 2 +- .../s0142_linked_list_cycle_ii/solution.ts | 2 +- .../ts/g0101_0200/s0146_lru_cache/solution.ts | 2 +- .../ts/g0101_0200/s0148_sort_list/solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../ts/g0101_0200/s0155_min_stack/solution.ts | 2 +- .../solution.ts | 2 +- .../s0169_majority_element/solution.ts | 2 +- .../g0101_0200/s0189_rotate_array/solution.ts | 2 +- .../g0101_0200/s0198_house_robber/solution.ts | 2 +- .../s0200_number_of_islands/solution.ts | 2 +- .../s0206_reverse_linked_list/solution.ts | 2 +- .../s0207_course_schedule/solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 15 +- 27 files changed, 152 insertions(+), 140 deletions(-) diff --git a/README.md b/README.md index 52c6915..effdd8a 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 #### Day 3 Two Pointers @@ -66,7 +66,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 #### Day 7 Breadth First Search Depth First Search @@ -121,7 +121,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 #### Day 16 Dynamic Programming @@ -222,7 +222,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 ### Binary Search II @@ -346,7 +346,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 4 @@ -365,13 +365,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 #### Day 7 | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 #### Day 8 @@ -382,7 +382,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 #### Day 10 @@ -506,7 +506,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 #### Day 11 Containers and Libraries @@ -593,7 +593,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 49 | 72.42 #### Day 15 @@ -615,7 +615,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 #### Day 19 @@ -633,7 +633,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 #### Day 2 Matrix Related Problems @@ -769,19 +769,19 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 #### Day 4 Linked List | | | | | | |-|-|-|-|-|- -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 51 | 76.99 #### Day 5 Greedy | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 #### Day 6 Tree @@ -804,7 +804,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 #### Day 10 Dynamic Programming @@ -864,7 +864,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 +| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 36 | 44.94 #### Day 5 Greedy @@ -911,7 +911,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 #### Day 13 Dynamic Programming @@ -919,7 +919,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 91 | 74.38 -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 #### Day 14 Sliding Window/Two Pointer @@ -938,8 +938,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 #### Day 17 Interval @@ -970,7 +970,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 53 | 83.14 | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 @@ -989,16 +989,16 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 #### Udemy Arrays | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 | 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 @@ -1017,7 +1017,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 #### Udemy Sorting Algorithms @@ -1037,17 +1037,17 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 +| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 51 | 76.99 +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 47 | 89.37 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 -| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 +| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 65 | 72.36 | 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 -| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 49 | 72.42 | 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 -| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 +| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 97 | 81.52 #### Udemy Tree Stack Queue @@ -1057,8 +1057,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 -| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 @@ -1066,21 +1066,21 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 #### Udemy Graph | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 #### Udemy Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 @@ -1108,7 +1108,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 ### Top Interview 150 @@ -1116,9 +1116,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 @@ -1152,7 +1152,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 -| 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 92 | 93.69 +| 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 34 | 90.07 #### Top Interview 150 Intervals @@ -1165,30 +1165,30 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 #### Top Interview 150 Linked List | | | | | | |-|-|-|-|-|- -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 47 | 89.37 | 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 2 | 95.82 | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 -| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 49 | 72.42 | 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 | 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 -| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 +| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 97 | 81.52 #### Top Interview 150 Binary Tree General | | | | | | |-|-|-|-|-|- -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 -| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 -| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 +| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 #### Top Interview 150 Binary Tree BFS @@ -1208,8 +1208,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -| 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 68 | 70.14 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 +| 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 #### Top Interview 150 Graph BFS @@ -1220,7 +1220,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 #### Top Interview 150 Backtracking @@ -1236,7 +1236,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 +| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 36 | 44.94 | 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 4 | 97.65 #### Top Interview 150 Kadane's Algorithm @@ -1253,21 +1253,21 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 | 0004 |[Median of Two Sorted Arrays](src/main/ts/g0001_0100/s0004_median_of_two_sorted_arrays/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Big_O_Time_O(log(min(N,M)))_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 82.74 #### Top Interview 150 Heap | | | | | | |-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 | 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 335 | 99.44 #### Top Interview 150 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 #### Top Interview 150 Math @@ -1280,8 +1280,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 | 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 @@ -1312,7 +1312,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 #### Day 4 Array @@ -1334,14 +1334,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 47 | 89.37 | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 #### Day 8 Linked List | | | | | | |-|-|-|-|-|- -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 #### Day 9 Stack Queue @@ -1360,7 +1360,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 #### Day 12 Tree @@ -1386,8 +1386,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 #### Day 2 Array @@ -1444,13 +1444,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 2 | 95.82 -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 51 | 76.99 #### Day 11 Linked List | | | | | | |-|-|-|-|-|- -| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 +| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 65 | 72.36 #### Day 12 Linked List @@ -1468,13 +1468,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 #### Day 15 Tree | | | | | | |-|-|-|-|-|- -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 #### Day 16 Tree @@ -1502,7 +1502,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 | 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 #### Day 21 Heap Priority Queue @@ -1522,7 +1522,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 #### Day 3 Two Pointers @@ -1567,7 +1567,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 #### Day 11 Recursion Backtracking @@ -1580,7 +1580,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 13 Bit Manipulation @@ -1591,7 +1591,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 ## Algorithms @@ -1623,32 +1623,32 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_II_Day_17_Tree, Level_2_Day_9_Binary_Search_Tree, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Level_2_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Data_Structure_II_Day_20_Heap_Priority_Queue, Top_Interview_150_Heap, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 148 | 54.45 -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Level_2_Day_16_Design, Udemy_Trie_and_Heap, Top_Interview_150_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 168 | 80.99 -| 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Top_Interview_150_Graph_General, Big_O_Time_O(N)_Space_O(N) | 68 | 70.14 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_8_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 51 | 92.87 -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search, Graph_Theory_I_Day_1_Matrix_Related_Problems, Level_1_Day_9_Graph/BFS/DFS, Udemy_Graph, Top_Interview_150_Graph_General, Big_O_Time_O(M\*N)_Space_O(M\*N) | 61 | 96.71 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_3, Level_2_Day_12_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 51 | 77.29 -| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Algorithm_I_Day_2_Two_Pointers, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 75 | 97.25 -| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Data_Structure_II_Day_1_Array, Udemy_Famous_Algorithm, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 50 | 96.16 -| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_II_Day_11_Linked_List, Udemy_Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 67 | 93.58 -| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Data_Structure_II_Day_14_Stack_Queue, Programming_Skills_II_Day_18, Level_2_Day_16_Design, Udemy_Design, Top_Interview_150_Stack, Big_O_Time_O(1)_Space_O(N) | 84 | 92.72 -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_I_Day_12, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 42 | 98.87 -| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Dynamic_Programming_I_Day_6, Level_2_Day_13_Dynamic_Programming, Udemy_Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 53 | 87.50 -| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Level_2_Day_4_Linked_List, Top_Interview_150_Divide_and_Conquer, Big_O_Time_O(log(N))_Space_O(log(N)) | 141 | 97.14 -| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 473 | 94.72 -| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_II_Day_10_Linked_List, Level_1_Day_4_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 94.39 -| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_I_Day_7_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(N)_Space_O(1) | 59 | 93.37 -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Algorithm_II_Day_15_Dynamic_Programming, Dynamic_Programming_I_Day_9, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 56 | 88.44 -| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Programming_Skills_II_Day_14, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(N)_Space_O(N) | 52 | 88.27 -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Data_Structure_II_Day_1_Array, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Integers, Top_Interview_150_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 56 | 85.48 -| 0131 |[Palindrome Partitioning](src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(N\*2^N)_Space_O(2^N\*N) | 203 | 99.22 -| 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Top_Interview_150_Hashmap, Big_O_Time_O(N_log_N)_Space_O(1) | 92 | 93.69 -| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 61 | 96.73 -| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Data_Structure_I_Day_3_Array, Dynamic_Programming_I_Day_7, Level_1_Day_5_Greedy, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(N)_Space_O(1) | 56 | 99.56 -| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Udemy_Linked_List, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 55 | 90.66 -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 65 | 96.47 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Programming_Skills_I_Day_10_Linked_List_and_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(H) | 51 | 97.14 +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Data_Structure_II_Day_20_Heap_Priority_Queue, Top_Interview_150_Heap, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Level_2_Day_16_Design, Udemy_Trie_and_Heap, Top_Interview_150_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 +| 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Top_Interview_150_Graph_General, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_8_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search, Graph_Theory_I_Day_1_Matrix_Related_Problems, Level_1_Day_9_Graph/BFS/DFS, Udemy_Graph, Top_Interview_150_Graph_General, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_3, Level_2_Day_12_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Algorithm_I_Day_2_Two_Pointers, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 +| 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Data_Structure_II_Day_1_Array, Udemy_Famous_Algorithm, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_II_Day_11_Linked_List, Udemy_Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 65 | 72.36 +| 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Data_Structure_II_Day_14_Stack_Queue, Programming_Skills_II_Day_18, Level_2_Day_16_Design, Udemy_Design, Top_Interview_150_Stack, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_I_Day_12, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 +| 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Dynamic_Programming_I_Day_6, Level_2_Day_13_Dynamic_Programming, Udemy_Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Level_2_Day_4_Linked_List, Top_Interview_150_Divide_and_Conquer, Big_O_Time_O(log(N))_Space_O(log(N)) | 36 | 44.94 +| 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 97 | 81.52 +| 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_II_Day_10_Linked_List, Level_1_Day_4_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 51 | 76.99 +| 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_I_Day_7_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(N)_Space_O(1) | 47 | 89.37 +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Algorithm_II_Day_15_Dynamic_Programming, Dynamic_Programming_I_Day_9, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 +| 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Programming_Skills_II_Day_14, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(N)_Space_O(N) | 49 | 72.42 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Data_Structure_II_Day_1_Array, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Integers, Top_Interview_150_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +| 0131 |[Palindrome Partitioning](src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(N\*2^N)_Space_O(2^N\*N) | 13 | 94.96 +| 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Top_Interview_150_Hashmap, Big_O_Time_O(N_log_N)_Space_O(1) | 34 | 90.07 +| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 +| 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Data_Structure_I_Day_3_Array, Dynamic_Programming_I_Day_7, Level_1_Day_5_Greedy, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 +| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Udemy_Linked_List, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Programming_Skills_I_Day_10_Linked_List_and_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_1_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_I_Day_14_Tree, Level_1_Day_8_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 diff --git a/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts b/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts index 1efe28d..5a8f158 100644 --- a/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts +++ b/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts @@ -2,7 +2,7 @@ // #Tree #Binary_Tree #Data_Structure_I_Day_11_Tree // #Programming_Skills_I_Day_10_Linked_List_and_Tree #Udemy_Tree_Stack_Queue // #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(N)_Space_O(H) -// #2023_10_04_Time_51_ms_(97.14%)_Space_46.1_MB_(68.29%) +// #2025_03_26_Time_0_ms_(100.00%)_Space_59.10_MB_(43.48%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts b/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts index dababbe..0c7ac6a 100644 --- a/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts +++ b/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Tree #Binary_Tree // #Divide_and_Conquer #Data_Structure_II_Day_15_Tree #Top_Interview_150_Binary_Tree_General -// #Big_O_Time_O(N)_Space_O(N) #2023_10_04_Time_65_ms_(96.47%)_Space_45.9_MB_(80.00%) +// #Big_O_Time_O(N)_Space_O(N) #2025_03_26_Time_2_ms_(93.38%)_Space_60.17_MB_(76.57%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts b/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts index 5941397..c33e52b 100644 --- a/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts +++ b/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree #Stack #Linked_List // #Udemy_Linked_List #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(N)_Space_O(N) -// #2023_10_04_Time_55_ms_(90.66%)_Space_45.8_MB_(12.11%) +// #2025_03_26_Time_0_ms_(100.00%)_Space_58.93_MB_(15.60%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts b/src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts index 11b0445..e55644f 100644 --- a/src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts +++ b/src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming // #Data_Structure_I_Day_3_Array #Dynamic_Programming_I_Day_7 #Level_1_Day_5_Greedy #Udemy_Arrays // #Top_Interview_150_Array/String #Big_O_Time_O(N)_Space_O(1) -// #2023_10_05_Time_56_ms_(99.56%)_Space_52.3_MB_(13.22%) +// #2025_03_26_Time_1_ms_(96.44%)_Space_65.83_MB_(26.02%) function maxProfit(prices: number[]): number { let buyPrice = prices[0] diff --git a/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts b/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts index 1118a0f..eb6995d 100644 --- a/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts +++ b/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Dynamic_Programming #Depth_First_Search // #Tree #Binary_Tree #Udemy_Tree_Stack_Queue #Top_Interview_150_Binary_Tree_General -// #Big_O_Time_O(N)_Space_O(N) #2023_10_05_Time_61_ms_(96.73%)_Space_51.2_MB_(97.45%) +// #Big_O_Time_O(N)_Space_O(N) #2025_03_26_Time_2_ms_(71.11%)_Space_65.59_MB_(42.96%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts b/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts index e69031e..4519a5d 100644 --- a/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts +++ b/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts @@ -1,18 +1,21 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Union_Find // #Top_Interview_150_Hashmap #Big_O_Time_O(N_log_N)_Space_O(1) -// #2023_10_05_Time_92_ms_(93.69%)_Space_64_MB_(30.13%) +// #2025_03_26_Time_34_ms_(90.07%)_Space_82.70_MB_(18.54%) function longestConsecutive(nums: number[]): number { - const set = new Set(nums) - let max = 0 - for (const num of nums) { - if (set.has(num + 1)) continue - let counter = 1, - current = num - while (set.has(--current)) counter++ - max = Math.max(counter, max) + let sset = new Set(nums) + let maxLen = 0 + for (let num of sset) { + // check its start of the sequence + if (!sset.has(num-1)) { + let len = 0; + while (sset.has(num+len)) { + len += 1 + } + maxLen = Math.max(maxLen, len) + } } - return max + return maxLen } export { longestConsecutive } diff --git a/src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts b/src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts index 32dca7c..406ce3d 100644 --- a/src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts +++ b/src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming // #Backtracking #Big_O_Time_O(N*2^N)_Space_O(2^N*N) -// #2023_10_05_Time_203_ms_(99.22%)_Space_81.9_MB_(42.19%) +// #2025_03_26_Time_13_ms_(94.96%)_Space_82.19_MB_(40.76%) function partition(s: string): string[][] { const ans: string[][] = [] diff --git a/src/main/ts/g0101_0200/s0136_single_number/solution.ts b/src/main/ts/g0101_0200/s0136_single_number/solution.ts index cc5faaf..6e15ea3 100644 --- a/src/main/ts/g0101_0200/s0136_single_number/solution.ts +++ b/src/main/ts/g0101_0200/s0136_single_number/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Bit_Manipulation // #Data_Structure_II_Day_1_Array #Algorithm_I_Day_14_Bit_Manipulation #Udemy_Integers // #Top_Interview_150_Bit_Manipulation #Big_O_Time_O(N)_Space_O(1) -// #2023_10_05_Time_56_ms_(85.48%)_Space_45.6_MB_(63.32%) +// #2025_03_26_Time_1_ms_(78.27%)_Space_58.44_MB_(41.08%) function singleNumber(nums: number[]): number { let ans = 0 diff --git a/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts b/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts index b633e45..27c0059 100644 --- a/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts +++ b/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Linked_List // #Programming_Skills_II_Day_14 #Udemy_Linked_List #Top_Interview_150_Linked_List -// #Big_O_Time_O(N)_Space_O(N) #2023_10_06_Time_52_ms_(88.27%)_Space_44.7_MB_(72.42%) +// #Big_O_Time_O(N)_Space_O(N) #2025_03_26_Time_49_ms_(72.42%)_Space_55.82_MB_(59.25%) import { Node } from '../../com_github_leetcode/node' diff --git a/src/main/ts/g0101_0200/s0139_word_break/solution.ts b/src/main/ts/g0101_0200/s0139_word_break/solution.ts index bba50d9..67b914f 100644 --- a/src/main/ts/g0101_0200/s0139_word_break/solution.ts +++ b/src/main/ts/g0101_0200/s0139_word_break/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table // #Dynamic_Programming #Trie #Memoization #Algorithm_II_Day_15_Dynamic_Programming // #Dynamic_Programming_I_Day_9 #Udemy_Dynamic_Programming #Top_Interview_150_1D_DP -// #Big_O_Time_O(M+max*N)_Space_O(M+N+max) #2023_10_06_Time_56_ms_(88.44%)_Space_44.1_MB_(93.39%) +// #Big_O_Time_O(M+max*N)_Space_O(M+N+max) #2025_03_26_Time_4_ms_(76.41%)_Space_58.68_MB_(22.70%) function wordBreak(s: string, wordDict: string[]): boolean { const dp: boolean[] = [] diff --git a/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts b/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts index ffdf669..282483e 100644 --- a/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts +++ b/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Two_Pointers #Linked_List // #Data_Structure_I_Day_7_Linked_List #Udemy_Linked_List #Top_Interview_150_Linked_List -// #Big_O_Time_O(N)_Space_O(1) #2023_10_06_Time_59_ms_(93.37%)_Space_45.2_MB_(76.28%) +// #Big_O_Time_O(N)_Space_O(1) #2025_03_26_Time_47_ms_(89.37%)_Space_58.35_MB_(35.02%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts b/src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts index 645027c..76b39d2 100644 --- a/src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts +++ b/src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Hash_Table #Two_Pointers #Linked_List // #Data_Structure_II_Day_10_Linked_List #Level_1_Day_4_Linked_List #Udemy_Linked_List -// #Big_O_Time_O(N)_Space_O(1) #2023_10_06_Time_59_ms_(94.39%)_Space_45.5_MB_(60.71%) +// #Big_O_Time_O(N)_Space_O(1) #2025_03_26_Time_51_ms_(76.99%)_Space_59.02_MB_(13.39%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0101_0200/s0146_lru_cache/solution.ts b/src/main/ts/g0101_0200/s0146_lru_cache/solution.ts index e36ba1e..9730a72 100644 --- a/src/main/ts/g0101_0200/s0146_lru_cache/solution.ts +++ b/src/main/ts/g0101_0200/s0146_lru_cache/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Design #Linked_List // #Doubly_Linked_List #Udemy_Linked_List #Top_Interview_150_Linked_List -// #Big_O_Time_O(1)_Space_O(capacity) #2023_10_06_Time_473_ms_(94.72%)_Space_125.1_MB_(69.62%) +// #Big_O_Time_O(1)_Space_O(capacity) #2025_03_26_Time_97_ms_(81.52%)_Space_108.56_MB_(48.32%) interface ICacheNode { key: number diff --git a/src/main/ts/g0101_0200/s0148_sort_list/solution.ts b/src/main/ts/g0101_0200/s0148_sort_list/solution.ts index a6a411e..a2a5988 100644 --- a/src/main/ts/g0101_0200/s0148_sort_list/solution.ts +++ b/src/main/ts/g0101_0200/s0148_sort_list/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Sorting #Two_Pointers #Linked_List // #Divide_and_Conquer #Merge_Sort #Level_2_Day_4_Linked_List #Top_Interview_150_Divide_and_Conquer -// #Big_O_Time_O(log(N))_Space_O(log(N)) #2023_10_08_Time_141_ms_(97.14%)_Space_71.9_MB_(47.35%) +// #Big_O_Time_O(log(N))_Space_O(log(N)) #2025_03_26_Time_36_ms_(44.94%)_Space_86.58_MB_(5.99%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts b/src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts index 111705f..64b02b9 100644 --- a/src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts +++ b/src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming // #Dynamic_Programming_I_Day_6 #Level_2_Day_13_Dynamic_Programming #Udemy_Dynamic_Programming -// #Big_O_Time_O(N)_Space_O(1) #2023_10_08_Time_53_ms_(87.50%)_Space_44.6_MB_(63.86%) +// #Big_O_Time_O(N)_Space_O(1) #2025_03_26_Time_0_ms_(100.00%)_Space_58.34_MB_(23.08%) function maxProduct(nums: number[]): number { let cMin = 1 diff --git a/src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts b/src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts index 02e0617..379c402 100644 --- a/src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts +++ b/src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Array #Binary_Search #Algorithm_II_Day_2_Binary_Search // #Binary_Search_I_Day_12 #Udemy_Binary_Search #Top_Interview_150_Binary_Search -// #Big_O_Time_O(log_N)_Space_O(log_N) #2023_10_08_Time_42_ms_(98.87%)_Space_42.9_MB_(84.75%) +// #Big_O_Time_O(log_N)_Space_O(log_N) #2025_03_26_Time_0_ms_(100.00%)_Space_55.42_MB_(40.88%) function findMin(nums: number[]): number { return Math.min(...nums) diff --git a/src/main/ts/g0101_0200/s0155_min_stack/solution.ts b/src/main/ts/g0101_0200/s0155_min_stack/solution.ts index 68fbd2b..9c29aa2 100644 --- a/src/main/ts/g0101_0200/s0155_min_stack/solution.ts +++ b/src/main/ts/g0101_0200/s0155_min_stack/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Stack #Design // #Data_Structure_II_Day_14_Stack_Queue #Programming_Skills_II_Day_18 #Level_2_Day_16_Design // #Udemy_Design #Top_Interview_150_Stack #Big_O_Time_O(1)_Space_O(N) -// #2023_10_08_Time_84_ms_(92.72%)_Space_51.8_MB_(30.46%) +// #2025_03_26_Time_5_ms_(99.10%)_Space_65.70_MB_(50.04%) class MinStack { stack: number[] diff --git a/src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts b/src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts index 7c4e990..18faf5d 100644 --- a/src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts +++ b/src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Two_Pointers #Linked_List // #Data_Structure_II_Day_11_Linked_List #Udemy_Linked_List #Big_O_Time_O(M+N)_Space_O(1) -// #2023_10_08_Time_67_ms_(93.58%)_Space_50.8_MB_(40.54%) +// #2025_03_26_Time_65_ms_(72.36%)_Space_63.62_MB_(41.12%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0101_0200/s0169_majority_element/solution.ts b/src/main/ts/g0101_0200/s0169_majority_element/solution.ts index ab52770..ad4b884 100644 --- a/src/main/ts/g0101_0200/s0169_majority_element/solution.ts +++ b/src/main/ts/g0101_0200/s0169_majority_element/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Sorting #Counting // #Divide_and_Conquer #Data_Structure_II_Day_1_Array #Udemy_Famous_Algorithm // #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(1) -// #2023_10_09_Time_50_ms_(96.16%)_Space_46.1_MB_(46.90%) +// #2025_03_26_Time_0_ms_(100.00%)_Space_60.31_MB_(17.26%) function majorityElement(arr: number[]): number { let count = 1 diff --git a/src/main/ts/g0101_0200/s0189_rotate_array/solution.ts b/src/main/ts/g0101_0200/s0189_rotate_array/solution.ts index ca7b07f..f645bc7 100644 --- a/src/main/ts/g0101_0200/s0189_rotate_array/solution.ts +++ b/src/main/ts/g0101_0200/s0189_rotate_array/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Math #Two_Pointers // #Algorithm_I_Day_2_Two_Pointers #Udemy_Arrays #Top_Interview_150_Array/String -// #Big_O_Time_O(n)_Space_O(1) #2023_10_09_Time_75_ms_(97.25%)_Space_52_MB_(63.34%) +// #Big_O_Time_O(n)_Space_O(1) #2025_03_26_Time_1_ms_(86.17%)_Space_64.71_MB_(43.34%) /* Do not return anything, modify nums in-place instead. diff --git a/src/main/ts/g0101_0200/s0198_house_robber/solution.ts b/src/main/ts/g0101_0200/s0198_house_robber/solution.ts index 1dba115..5340eb8 100644 --- a/src/main/ts/g0101_0200/s0198_house_robber/solution.ts +++ b/src/main/ts/g0101_0200/s0198_house_robber/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming // #Algorithm_I_Day_12_Dynamic_Programming #Dynamic_Programming_I_Day_3 // #Level_2_Day_12_Dynamic_Programming #Udemy_Dynamic_Programming #Top_Interview_150_1D_DP -// #Big_O_Time_O(n)_Space_O(n) #2023_10_09_Time_51_ms_(77.29%)_Space_42.7_MB_(62.58%) +// #Big_O_Time_O(n)_Space_O(n) #2025_03_26_Time_0_ms_(100.00%)_Space_55.74_MB_(28.06%) function rob(nums: number[]): number { const n = nums.length diff --git a/src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts b/src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts index 5408d4f..87b9e95 100644 --- a/src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts +++ b/src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts @@ -3,7 +3,7 @@ // #Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search // #Graph_Theory_I_Day_1_Matrix_Related_Problems #Level_1_Day_9_Graph/BFS/DFS #Udemy_Graph // #Top_Interview_150_Graph_General #Big_O_Time_O(M*N)_Space_O(M*N) -// #2023_10_09_Time_61_ms_(96.71%)_Space_44.5_MB_(99.30%) +// #2025_03_26_Time_57_ms_(93.94%)_Space_59.21_MB_(64.22%) function numIslands(grid: string[][]): number { let islands = 0 diff --git a/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts b/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts index 513c8c4..5f0eb57 100644 --- a/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts +++ b/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Linked_List #Recursion // #Data_Structure_I_Day_8_Linked_List #Algorithm_I_Day_10_Recursion_Backtracking // #Level_1_Day_3_Linked_List #Udemy_Linked_List #Big_O_Time_O(N)_Space_O(1) -// #2023_10_09_Time_51_ms_(92.87%)_Space_44.3_MB_(96.03%) +// #2025_03_26_Time_0_ms_(100.00%)_Space_58.92_MB_(16.01%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts b/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts index dd108fa..7ca00b4 100644 --- a/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts +++ b/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search // #Breadth_First_Search #Graph #Topological_Sort #Top_Interview_150_Graph_General -// #Big_O_Time_O(N)_Space_O(N) #2023_10_09_Time_68_ms_(70.14%)_Space_47.7_MB_(73.55%) +// #Big_O_Time_O(N)_Space_O(N) #2025_03_26_Time_11_ms_(81.08%)_Space_62.76_MB_(51.00%) const WHITE = 0 const GRAY = 1 diff --git a/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts b/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts index 24f299b..53a753e 100644 --- a/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts +++ b/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Design #Trie // #Level_2_Day_16_Design #Udemy_Trie_and_Heap #Top_Interview_150_Trie // #Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) -// #2023_10_09_Time_168_ms_(80.99%)_Space_79.5_MB_(14.46%) +// #2025_03_26_Time_48_ms_(63.95%)_Space_81.97_MB_(12.22%) class TrieNode { children: TrieNode[] diff --git a/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts b/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts index ed7e619..87fa919 100644 --- a/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts +++ b/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts @@ -1,11 +1,20 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting #Heap_Priority_Queue // #Divide_and_Conquer #Quickselect #Data_Structure_II_Day_20_Heap_Priority_Queue // #Top_Interview_150_Heap #Big_O_Time_O(n*log(n))_Space_O(log(n)) -// #2023_10_09_Time_148_ms_(54.45%)_Space_51.5_MB_(73.60%) +// #2025_03_26_Time_4_ms_(99.64%)_Space_66.28_MB_(62.13%) function findKthLargest(nums: number[], k: number): number { - nums.sort((prev, next) => next - prev) - return nums[k - 1] + const countingLen = 2e4 + 1 + const counting = new Int32Array(countingLen) + for (const num of nums) { + counting[num + 1e4]++; + } + for (let i = countingLen - 1; i >= 0; i--) { + k -= counting[i] + if (k <= 0) { + return i - 1e4 + } + } } export { findKthLargest } From 0bcae35f86afc2b22087bf8c84d6f8d05dcb8fa7 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 28 Mar 2025 05:41:23 +0200 Subject: [PATCH 15/49] Improved tasks 221-1143 --- README.md | 154 +++++++++--------- .../s0221_maximal_square/solution.ts | 2 +- .../s0226_invert_binary_tree/solution.ts | 2 +- .../solution.ts | 2 +- .../s0234_palindrome_linked_list/solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../s0239_sliding_window_maximum/solution.ts | 2 +- .../s0240_search_a_2d_matrix_ii/solution.ts | 2 +- .../g0201_0300/s0283_move_zeroes/solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../g0301_0400/s0322_coin_change/solution.ts | 2 +- .../s0338_counting_bits/solution.ts | 2 +- .../s0347_top_k_frequent_elements/solution.ts | 2 +- .../s0394_decode_string/solution.ts | 2 +- .../solution.ts | 2 +- .../g0401_0500/s0437_path_sum_iii/solution.ts | 2 +- .../solution.ts | 2 +- .../g0401_0500/s0494_target_sum/solution.ts | 2 +- .../s0543_diameter_of_binary_tree/solution.ts | 2 +- .../s0560_subarray_sum_equals_k/solution.ts | 2 +- .../s0647_palindromic_substrings/solution.ts | 2 +- .../s0739_daily_temperatures/solution.ts | 2 +- .../s0763_partition_labels/solution.ts | 2 +- .../solution.ts | 2 +- 27 files changed, 103 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index effdd8a..c24e68c 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 #### Day 6 Breadth First Search Depth First Search @@ -127,20 +127,20 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 #### Day 17 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 #### Day 18 Dynamic Programming | | | | | | |-|-|-|-|-|- | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 #### Day 19 Bit Manipulation @@ -240,7 +240,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 #### Day 4 @@ -251,7 +251,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 +| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 5 | 88.65 #### Day 6 @@ -267,7 +267,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 42 | 94.61 #### Day 9 @@ -422,7 +422,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 -| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 +| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 #### Day 17 @@ -434,20 +434,20 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 #### Day 19 | | | | | | |-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 #### Day 20 | | | | | | |-|-|-|-|-|- -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 #### Day 21 @@ -485,7 +485,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 #### Day 7 Array @@ -549,7 +549,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 194 | 97.36 +| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 18 | 80.57 #### Day 7 @@ -582,7 +582,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 #### Day 13 @@ -822,7 +822,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 #### Day 13 Hashmap @@ -834,7 +834,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 15 Heap @@ -858,7 +858,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 3 | 92.85 #### Day 4 Linked List @@ -875,14 +875,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 7 Tree | | | | | | |-|-|-|-|-|- -| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 -| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 +| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 1 | 87.16 +| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 3 | 86.41 #### Day 8 Binary Search @@ -895,7 +895,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 10 Graph/BFS/DFS @@ -912,13 +912,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 #### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 91 | 74.38 +| 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 33 | 93.24 | 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 #### Day 14 Sliding Window/Two Pointer @@ -981,7 +981,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 #### Udemy Binary Search @@ -996,14 +996,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 | 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 1 | 99.11 -| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 +| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 26 | 99.07 #### Udemy Two Pointers @@ -1044,7 +1044,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 | 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 65 | 72.36 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 3 | 92.85 | 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 49 | 72.42 | 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 | 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 97 | 81.52 @@ -1055,12 +1055,12 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 1 | 87.16 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 #### Udemy Trie and Heap @@ -1083,8 +1083,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 5 | 90.44 @@ -1102,7 +1102,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 +| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 1 | 89.22 #### Udemy Design @@ -1121,7 +1121,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 2 | 99.08 @@ -1184,12 +1184,12 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 #### Top Interview 150 Binary Tree BFS @@ -1201,7 +1201,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 #### Top Interview 150 Graph General @@ -1261,7 +1261,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 -| 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 335 | 99.44 +| 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 106 | 92.31 #### Top Interview 150 Bit Manipulation @@ -1282,8 +1282,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 #### Top Interview 150 Multidimensional DP @@ -1292,7 +1292,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 -| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 +| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 ### Data Structure I @@ -1367,7 +1367,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 13 Tree @@ -1407,14 +1407,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 42 | 94.61 #### Day 5 Array | | | | | | |-|-|-|-|-|- -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 70 | 92.45 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 +| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 14 | 87.34 #### Day 6 String @@ -1425,7 +1425,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 3 | 97.96 +| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 4 | 86.89 #### Day 8 String @@ -1485,13 +1485,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 18 Tree | | | | | | |-|-|-|-|-|- -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 #### Day 19 Graph @@ -1503,7 +1503,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 -| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 +| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 7 | 87.13 #### Day 21 Heap Priority Queue @@ -1528,7 +1528,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 #### Day 4 Two Pointers @@ -1597,32 +1597,32 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | # | Title | Difficulty | Tag | Time, ms | Time, % |------|----------------|-------------|-------------|----------|--------- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_17_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 94 | 80.56 -| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | String, Hash_Table, Greedy, Two_Pointers, Data_Structure_II_Day_7_String, Big_O_Time_O(n)_Space_O(1) | 3 | 97.96 -| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Programming_Skills_II_Day_6, Big_O_Time_O(n)_Space_O(n) | 194 | 97.36 -| 0647 |[Palindromic Substrings](src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts)| Medium | String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n) | 60 | 89.76 -| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Data_Structure_II_Day_5_Array, Big_O_Time_O(n)_Space_O(n) | 70 | 92.45 -| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 61 | 80.89 -| 0494 |[Target Sum](src/main/ts/g0401_0500/s0494_target_sum/solution.ts)| Medium | Array, Dynamic_Programming, Backtracking, Big_O_Time_O(n\*(sum+s))_Space_O(n\*(sum+s)) | 77 | 81.99 -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Programming_Skills_II_Day_12, Level_1_Day_12_Sliding_Window/Two_Pointer, Big_O_Time_O(n+m)_Space_O(1) | 69 | 96.69 -| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Big_O_Time_O(n)_Space_O(n) | 68 | 86.71 -| 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Level_2_Day_13_Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 91 | 74.38 -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Level_1_Day_14_Stack, Udemy_Strings, Big_O_Time_O(n)_Space_O(n) | 51 | 81.02 -| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Data_Structure_II_Day_20_Heap_Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(k) | 62 | 87.48 -| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Udemy_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 69 | 86.81 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_20, Level_2_Day_12_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(m\*n)_Space_O(amount) | 85 | 86.14 -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Algorithm_II_Day_16_Dynamic_Programming, Binary_Search_II_Day_3, Dynamic_Programming_I_Day_18, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n\*log_n)_Space_O(n) | 57 | 93.75 -| 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Top_Interview_150_Heap, Big_O_Time_O(n\*log_n)_Space_O(n) | 335 | 99.44 -| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Binary_Search_II_Day_5, Big_O_Time_O(n)_Space_O(n) | 60 | 98.11 -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Programming_Skills_I_Day_6_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 71 | 91.63 -| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Data_Structure_II_Day_4_Array, Binary_Search_II_Day_8, Big_O_Time_O(n+m)_Space_O(1) | 58 | 64.44 -| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Udemy_Arrays, Big_O_Time_O(n\*k)_Space_O(n+k) | 216 | 99.50 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Data_Structure_II_Day_5_Array, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 89 | 64.48 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_18_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 59 | 96.11 -| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Level_2_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 96 | 95.67 -| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_II_Day_17_Tree, Level_2_Day_9_Binary_Search_Tree, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 54 | 97.22 -| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Level_2_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 52 | 81.65 -| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 83 | 79.70 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_17_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 +| 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | String, Hash_Table, Greedy, Two_Pointers, Data_Structure_II_Day_7_String, Big_O_Time_O(n)_Space_O(1) | 4 | 86.89 +| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Programming_Skills_II_Day_6, Big_O_Time_O(n)_Space_O(n) | 18 | 80.57 +| 0647 |[Palindromic Substrings](src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts)| Medium | String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n) | 5 | 100.00 +| 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Data_Structure_II_Day_5_Array, Big_O_Time_O(n)_Space_O(n) | 14 | 87.34 +| 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 1 | 87.16 +| 0494 |[Target Sum](src/main/ts/g0401_0500/s0494_target_sum/solution.ts)| Medium | Array, Dynamic_Programming, Backtracking, Big_O_Time_O(n\*(sum+s))_Space_O(n\*(sum+s)) | 24 | 83.43 +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Programming_Skills_II_Day_12, Level_1_Day_12_Sliding_Window/Two_Pointer, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 +| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Big_O_Time_O(n)_Space_O(n) | 3 | 86.41 +| 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Level_2_Day_13_Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 33 | 93.24 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Level_1_Day_14_Stack, Udemy_Strings, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Data_Structure_II_Day_20_Heap_Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(k) | 7 | 87.13 +| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Udemy_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 1 | 89.22 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_20, Level_2_Day_12_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Algorithm_II_Day_16_Dynamic_Programming, Binary_Search_II_Day_3, Dynamic_Programming_I_Day_18, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 +| 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Top_Interview_150_Heap, Big_O_Time_O(n\*log_n)_Space_O(n) | 106 | 92.31 +| 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Binary_Search_II_Day_5, Big_O_Time_O(n)_Space_O(n) | 5 | 88.65 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Programming_Skills_I_Day_6_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 +| 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Data_Structure_II_Day_4_Array, Binary_Search_II_Day_8, Big_O_Time_O(n+m)_Space_O(1) | 42 | 94.61 +| 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Udemy_Arrays, Big_O_Time_O(n\*k)_Space_O(n+k) | 26 | 99.07 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Data_Structure_II_Day_5_Array, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_18_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 +| 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Level_2_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 3 | 92.85 +| 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_II_Day_17_Tree, Level_2_Day_9_Binary_Search_Tree, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Level_2_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 | 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Data_Structure_II_Day_20_Heap_Priority_Queue, Top_Interview_150_Heap, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 | 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Level_2_Day_16_Design, Udemy_Trie_and_Heap, Top_Interview_150_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 | 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Top_Interview_150_Graph_General, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 diff --git a/src/main/ts/g0201_0300/s0221_maximal_square/solution.ts b/src/main/ts/g0201_0300/s0221_maximal_square/solution.ts index 0137581..81cafc9 100644 --- a/src/main/ts/g0201_0300/s0221_maximal_square/solution.ts +++ b/src/main/ts/g0201_0300/s0221_maximal_square/solution.ts @@ -1,6 +1,6 @@ // #Medium #Array #Dynamic_Programming #Matrix #Dynamic_Programming_I_Day_16 // #Top_Interview_150_Multidimensional_DP #Big_O_Time_O(m*n)_Space_O(m*n) -// #2023_10_09_Time_83_ms_(79.70%)_Space_50.2_MB_(56.39%) +// #2025_03_28_Time_18_ms_(59.02%)_Space_66.03_MB_(29.27%) function maximalSquare(matrix: string[][]): number { const m = matrix.length diff --git a/src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts b/src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts index 2b2a6d4..4887133 100644 --- a/src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts +++ b/src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree // #Data_Structure_I_Day_12_Tree #Level_2_Day_6_Tree #Udemy_Tree_Stack_Queue // #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(n)_Space_O(n) -// #2023_10_09_Time_52_ms_(81.65%)_Space_44.2_MB_(79.49%) +// #2025_03_28_Time_0_ms_(100.00%)_Space_55.85_MB_(47.98%) function invertTree(root: TreeNode | null): TreeNode | null { if (root === null) { diff --git a/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts b/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts index 53cb174..4bb3fc1 100644 --- a/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts +++ b/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree #Binary_Search_Tree // #Data_Structure_II_Day_17_Tree #Level_2_Day_9_Binary_Search_Tree // #Top_Interview_150_Binary_Search_Tree #Big_O_Time_O(n)_Space_O(n) -// #2023_10_09_Time_54_ms_(97.22%)_Space_47.7_MB_(99.80%) +// #2025_03_28_Time_0_ms_(100.00%)_Space_61.27_MB_(52.69%) /* * Definition for a binary tree node. diff --git a/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts b/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts index aedaef3..b9e8004 100644 --- a/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts +++ b/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Two_Pointers #Stack #Linked_List #Recursion // #Level_2_Day_3_Linked_List #Udemy_Linked_List #Big_O_Time_O(n)_Space_O(1) -// #2023_10_09_Time_96_ms_(95.67%)_Space_72.8_MB_(87.01%) +// #2025_03_28_Time_3_ms_(92.85%)_Space_79.85_MB_(44.75%) /* * Definition for singly-linked list. diff --git a/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts b/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts index 7823021..7a50797 100644 --- a/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts +++ b/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree // #Data_Structure_II_Day_18_Tree #Udemy_Tree_Stack_Queue #Top_Interview_150_Binary_Tree_General -// #Big_O_Time_O(n)_Space_O(n) #2023_10_09_Time_59_ms_(96.11%)_Space_52.8_MB_(24.18%) +// #Big_O_Time_O(n)_Space_O(n) #2025_03_28_Time_61_ms_(75.97%)_Space_65.98_MB_(36.62%) /* * Definition for a binary tree node. diff --git a/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts b/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts index 811e0a7..6ab8a94 100644 --- a/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts +++ b/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Array #Prefix_Sum #Data_Structure_II_Day_5_Array #Udemy_Arrays // #Top_Interview_150_Array/String #Big_O_Time_O(n^2)_Space_O(n) -// #2023_10_09_Time_89_ms_(64.48%)_Space_55.4_MB_(36.71%) +// #2025_03_28_Time_3_ms_(92.81%)_Space_70.08_MB_(42.74%) function productExceptSelf(nums: number[]): number[] { const n = nums.length diff --git a/src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts b/src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts index 699f267..5f944d0 100644 --- a/src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts +++ b/src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Array #Heap_Priority_Queue #Sliding_Window #Queue // #Monotonic_Queue #Udemy_Arrays #Big_O_Time_O(n*k)_Space_O(n+k) -// #2023_10_06_Time_216_ms_(99.50%)_Space_71.4_MB_(89.85%) +// #2025_03_28_Time_26_ms_(99.07%)_Space_86.22_MB_(58.38%) function maxSlidingWindow(nums: number[], k: number): number[] { const result: number[] = [] diff --git a/src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts b/src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts index f0c503d..beef395 100644 --- a/src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts +++ b/src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Array #Binary_Search #Matrix #Divide_and_Conquer // #Data_Structure_II_Day_4_Array #Binary_Search_II_Day_8 #Big_O_Time_O(n+m)_Space_O(1) -// #2023_10_06_Time_58_ms_(64.44%)_Space_45.6_MB_(50.00%) +// #2025_03_28_Time_42_ms_(94.61%)_Space_58.52_MB_(36.53%) function searchMatrix(matrix: number[][], target: number): boolean { let r: number = 0 diff --git a/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts b/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts index 7ef6a9b..774c180 100644 --- a/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts +++ b/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Array #Two_Pointers #Algorithm_I_Day_3_Two_Pointers // #Programming_Skills_I_Day_6_Array #Udemy_Arrays #Big_O_Time_O(n)_Space_O(1) -// #2023_10_06_Time_71_ms_(91.63%)_Space_47.2_MB_(57.52%) +// #2025_03_28_Time_1_ms_(82.86%)_Space_62.16_MB_(10.71%) /* Do not return anything, modify nums in-place instead. diff --git a/src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts b/src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts index dc8ada3..9bcd4ee 100644 --- a/src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts +++ b/src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Array #Binary_Search #Two_Pointers #Bit_Manipulation // #Binary_Search_II_Day_5 #Big_O_Time_O(n)_Space_O(n) -// #2023_10_06_Time_60_ms_(98.11%)_Space_53.5_MB_(50.00%) +// #2025_03_28_Time_5_ms_(88.65%)_Space_67.23_MB_(32.75%) function findDuplicate(nums: number[]): number { const arr: number[] = new Array(nums.length + 1).fill(0) diff --git a/src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts b/src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts index b46275f..99e79e2 100644 --- a/src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts +++ b/src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts @@ -1,6 +1,6 @@ // #Hard #Top_100_Liked_Questions #Sorting #Two_Pointers #Design #Heap_Priority_Queue #Data_Stream // #Top_Interview_150_Heap #Big_O_Time_O(n*log_n)_Space_O(n) -// #2023_10_13_Time_335_ms_(99.44%)_Space_96.8_MB_(69.49%) +// #2025_03_28_Time_106_ms_(92.31%)_Space_94.21_MB_(5.43%) class Heap { private heap: number[] diff --git a/src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts b/src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts index 0c459e9..c45a8f5 100644 --- a/src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts +++ b/src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Binary_Search // #Algorithm_II_Day_16_Dynamic_Programming #Binary_Search_II_Day_3 #Dynamic_Programming_I_Day_18 // #Udemy_Dynamic_Programming #Top_Interview_150_1D_DP #Big_O_Time_O(n*log_n)_Space_O(n) -// #2023_10_04_Time_57_ms_(93.75%)_Space_45_MB_(33.55%) +// #2025_03_28_Time_6_ms_(84.68%)_Space_58.13_MB_(39.69%) function lengthOfLIS(nums: number[]): number { if (nums === null || nums.length === 0) { diff --git a/src/main/ts/g0301_0400/s0322_coin_change/solution.ts b/src/main/ts/g0301_0400/s0322_coin_change/solution.ts index 9fb67cd..c9cc931 100644 --- a/src/main/ts/g0301_0400/s0322_coin_change/solution.ts +++ b/src/main/ts/g0301_0400/s0322_coin_change/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Breadth_First_Search // #Algorithm_II_Day_18_Dynamic_Programming #Dynamic_Programming_I_Day_20 // #Level_2_Day_12_Dynamic_Programming #Top_Interview_150_1D_DP #Big_O_Time_O(m*n)_Space_O(amount) -// #2023_10_04_Time_85_ms_(86.14%)_Space_47.7_MB_(84.40%) +// #2025_03_28_Time_27_ms_(89.42%)_Space_61.11_MB_(55.40%) function coinChange(coins: number[], amount: number): number { const dp: number[] = new Array(amount + 1).fill(0) diff --git a/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts b/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts index 07708da..29b4577 100644 --- a/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts +++ b/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts @@ -1,5 +1,5 @@ // #Easy #Dynamic_Programming #Bit_Manipulation #Udemy_Bit_Manipulation -// #Big_O_Time_O(num)_Space_O(num) #2023_10_04_Time_69_ms_(86.81%)_Space_49_MB_(78.01%) +// #Big_O_Time_O(num)_Space_O(num) #2025_03_28_Time_1_ms_(89.22%)_Space_62.26_MB_(53.31%) function countBits(n: number): number[] { const bits: number[] = [0] diff --git a/src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts b/src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts index fcc2d4b..d925d9e 100644 --- a/src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts +++ b/src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Array #Hash_Table #Sorting #Heap_Priority_Queue #Counting // #Divide_and_Conquer #Quickselect #Bucket_Sort #Data_Structure_II_Day_20_Heap_Priority_Queue -// #Big_O_Time_O(n*log(n))_Space_O(k) #2023_10_04_Time_62_ms_(87.48%)_Space_45.6_MB_(67.84%) +// #Big_O_Time_O(n*log(n))_Space_O(k) #2025_03_28_Time_7_ms_(87.13%)_Space_59.57_MB_(56.27%) function topKFrequent(nums: number[], k: number): number[] { let elementCount = new Array(nums.length) diff --git a/src/main/ts/g0301_0400/s0394_decode_string/solution.ts b/src/main/ts/g0301_0400/s0394_decode_string/solution.ts index 6adb121..e031a64 100644 --- a/src/main/ts/g0301_0400/s0394_decode_string/solution.ts +++ b/src/main/ts/g0301_0400/s0394_decode_string/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #String #Stack #Recursion #Level_1_Day_14_Stack #Udemy_Strings -// #Big_O_Time_O(n)_Space_O(n) #2023_10_04_Time_51_ms_(81.02%)_Space_43_MB_(55.52%) +// #Big_O_Time_O(n)_Space_O(n) #2025_03_28_Time_0_ms_(100.00%)_Space_55.70_MB_(34.63%) function decodeString(s: string): string { let stack: string[] = [] diff --git a/src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts b/src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts index 5ad6375..aa05ea4 100644 --- a/src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts +++ b/src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Level_2_Day_13_Dynamic_Programming -// #Big_O_Time_O(n*sums)_Space_O(n*sums) #2023_09_30_Time_91_ms_(74.38%)_Space_44.7_MB_(83.25%) +// #Big_O_Time_O(n*sums)_Space_O(n*sums) #2025_03_28_Time_33_ms_(93.24%)_Space_59.12_MB_(71.50%) function canPartition(nums: number[]): boolean { let sums: number = 0 diff --git a/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts b/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts index 266804a..77843eb 100644 --- a/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts +++ b/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts @@ -1,5 +1,5 @@ // #Medium #Depth_First_Search #Tree #Binary_Tree #Level_2_Day_7_Tree #Big_O_Time_O(n)_Space_O(n) -// #2023_09_30_Time_68_ms_(86.71%)_Space_47.3_MB_(98.10%) +// #2025_03_28_Time_3_ms_(86.41%)_Space_61.43_MB_(43.21%) function pathSum(root: TreeNode | null, targetSum: number): number { let count = 0 diff --git a/src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts b/src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts index 4b72af7..6cd3d9b 100644 --- a/src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts +++ b/src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #String #Hash_Table #Sliding_Window // #Algorithm_II_Day_5_Sliding_Window #Programming_Skills_II_Day_12 // #Level_1_Day_12_Sliding_Window/Two_Pointer #Big_O_Time_O(n+m)_Space_O(1) -// #2023_09_30_Time_69_ms_(96.69%)_Space_46.1_MB_(80.99%) +// #2025_03_28_Time_8_ms_(97.80%)_Space_59.42_MB_(72.16%) function findAnagrams(s: string, p: string): number[] { const map: number[] = new Array(26).fill(0) diff --git a/src/main/ts/g0401_0500/s0494_target_sum/solution.ts b/src/main/ts/g0401_0500/s0494_target_sum/solution.ts index 1dddfb5..0e08730 100644 --- a/src/main/ts/g0401_0500/s0494_target_sum/solution.ts +++ b/src/main/ts/g0401_0500/s0494_target_sum/solution.ts @@ -1,5 +1,5 @@ // #Medium #Array #Dynamic_Programming #Backtracking #Big_O_Time_O(n*(sum+s))_Space_O(n*(sum+s)) -// #2023_09_30_Time_77_ms_(81.99%)_Space_48.3_MB_(62.73%) +// #2025_03_28_Time_24_ms_(83.43%)_Space_63.15_MB_(21.89%) function findTargetSumWays(nums: number[], s: number): number { let sum: number = 0 diff --git a/src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts b/src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts index db0215c..1480bfa 100644 --- a/src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts +++ b/src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts @@ -1,6 +1,6 @@ // #Easy #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree #Level_2_Day_7_Tree // #Udemy_Tree_Stack_Queue #Big_O_Time_O(n)_Space_O(n) -// #2023_09_30_Time_61_ms_(80.89%)_Space_47.4_MB_(18.15%) +// #2025_03_28_Time_1_ms_(87.16%)_Space_63.47_MB_(59.51%) function diameterOfBinaryTree(root: TreeNode | null): number { let ans = 0 diff --git a/src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts b/src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts index 831ff8d..3ccaa10 100644 --- a/src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts +++ b/src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Array #Hash_Table #Prefix_Sum #Data_Structure_II_Day_5_Array -// #Big_O_Time_O(n)_Space_O(n) #2023_09_30_Time_70_ms_(92.45%)_Space_52.7_MB_(27.70%) +// #Big_O_Time_O(n)_Space_O(n) #2025_03_28_Time_14_ms_(87.34%)_Space_67.32_MB_(18.02%) function subarraySum(nums: number[], k: number): number { let tempSum: number = 0 diff --git a/src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts b/src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts index 4c31fc3..e4fc2ab 100644 --- a/src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts +++ b/src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts @@ -1,5 +1,5 @@ // #Medium #String #Dynamic_Programming #Big_O_Time_O(n^2)_Space_O(n) -// #2023_09_30_Time_60_ms_(89.76%)_Space_43_MB_(93.98%) +// #2025_03_28_Time_5_ms_(100.00%)_Space_56.80_MB_(51.20%) function expand(a: string[], l: number, r: number, res: number[]): void { while (l >= 0 && r < a.length) { diff --git a/src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts b/src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts index 77f9d78..e1bbbcc 100644 --- a/src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts +++ b/src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Array #Stack #Monotonic_Stack #Programming_Skills_II_Day_6 -// #Big_O_Time_O(n)_Space_O(n) #2023_09_30_Time_194_ms_(97.36%)_Space_66.2_MB_(69.52%) +// #Big_O_Time_O(n)_Space_O(n) #2025_03_28_Time_18_ms_(80.57%)_Space_78.12_MB_(62.08%) function dailyTemperatures(temperatures: number[]): number[] { let stack: number[] = [] diff --git a/src/main/ts/g0701_0800/s0763_partition_labels/solution.ts b/src/main/ts/g0701_0800/s0763_partition_labels/solution.ts index b9b2a63..a9fdb0e 100644 --- a/src/main/ts/g0701_0800/s0763_partition_labels/solution.ts +++ b/src/main/ts/g0701_0800/s0763_partition_labels/solution.ts @@ -1,5 +1,5 @@ // #Medium #String #Hash_Table #Greedy #Two_Pointers #Data_Structure_II_Day_7_String -// #Big_O_Time_O(n)_Space_O(1) #2025_02_15_Time_3_ms_(97.96%)_Space_52.21_MB_(88.78%) +// #Big_O_Time_O(n)_Space_O(1) #2025_03_28_Time_4_ms_(86.89%)_Space_58.06_MB_(34.43%) function partitionLabels(s: string): number[] { const map = new Map() diff --git a/src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts b/src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts index ddfcd36..bfdf6bf 100644 --- a/src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts +++ b/src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #String #Dynamic_Programming // #Algorithm_II_Day_17_Dynamic_Programming #Dynamic_Programming_I_Day_19 // #Udemy_Dynamic_Programming #Big_O_Time_O(n*m)_Space_O(n*m) -// #2023_09_30_Time_94_ms_(80.56%)_Space_73.5_MB_(53.24%) +// #2025_03_28_Time_50_ms_(69.40%)_Space_85.72_MB_(16.94%) function longestCommonSubsequence(text1: string, text2: string): number { const n: number = text1.length From aacba4a4fd8305db90f34ce77ae15dfdb0ae8ce4 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Mon, 31 Mar 2025 23:14:34 +0700 Subject: [PATCH 16/49] Added tasks 12-28 --- README.md | 16 +++++ .../s0012_integer_to_roman/readme.md | 62 ++++++++++++++++++ .../s0012_integer_to_roman/solution.ts | 23 +++++++ .../s0013_roman_to_integer/readme.md | 64 +++++++++++++++++++ .../s0013_roman_to_integer/solution.ts | 51 +++++++++++++++ .../s0014_longest_common_prefix/readme.md | 27 ++++++++ .../s0014_longest_common_prefix/solution.ts | 29 +++++++++ .../readme.md | 49 ++++++++++++++ .../solution.ts | 21 ++++++ .../g0001_0100/s0027_remove_element/readme.md | 52 +++++++++++++++ .../s0027_remove_element/solution.ts | 34 ++++++++++ .../readme.md | 36 +++++++++++ .../solution.ts | 19 ++++++ .../s0012_integer_to_roman/solution.test.ts | 15 +++++ .../s0013_roman_to_integer/solution.test.ts | 15 +++++ .../solution.test.ts | 11 ++++ .../solution.test.ts | 11 ++++ .../s0027_remove_element/solution.test.ts | 11 ++++ .../solution.test.ts | 11 ++++ 19 files changed, 557 insertions(+) create mode 100644 src/main/ts/g0001_0100/s0012_integer_to_roman/readme.md create mode 100644 src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts create mode 100644 src/main/ts/g0001_0100/s0013_roman_to_integer/readme.md create mode 100644 src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts create mode 100644 src/main/ts/g0001_0100/s0014_longest_common_prefix/readme.md create mode 100644 src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts create mode 100644 src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/readme.md create mode 100644 src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts create mode 100644 src/main/ts/g0001_0100/s0027_remove_element/readme.md create mode 100644 src/main/ts/g0001_0100/s0027_remove_element/solution.ts create mode 100644 src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/readme.md create mode 100644 src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts create mode 100644 src/test/ts/g0001_0100/s0012_integer_to_roman/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0013_roman_to_integer/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.test.ts diff --git a/README.md b/README.md index c24e68c..f9bc867 100644 --- a/README.md +++ b/README.md @@ -524,6 +524,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0028 |[Implement strStr()](src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 #### Day 2 @@ -852,6 +853,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0014 |[Longest Common Prefix](src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String | 0 | 100.00 #### Day 3 Linked List @@ -978,6 +980,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0014 |[Longest Common Prefix](src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String | 0 | 100.00 | 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 @@ -1009,6 +1012,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0026 |[Remove Duplicates from Sorted Array](src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 @@ -1116,6 +1120,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0027 |[Remove Element](src/main/ts/g0001_0100/s0027_remove_element/solution.ts)| Easy | Array, Two_Pointers | 0 | 100.00 +| 0026 |[Remove Duplicates from Sorted Array](src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 @@ -1123,7 +1129,11 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0013 |[Roman to Integer](src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Math | 3 | 94.58 +| 0012 |[Integer to Roman](src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts)| Medium | String, Hash_Table, Math | 3 | 93.02 +| 0014 |[Longest Common Prefix](src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String | 0 | 100.00 | 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 2 | 99.08 +| 0028 |[Implement strStr()](src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 #### Top Interview 150 Two Pointers @@ -1681,6 +1691,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_11, Level_2_Day_8_Binary_Search, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0032 |[Longest Valid Parentheses](src/main/ts/g0001_0100/s0032_longest_valid_parentheses/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Stack, Big_O_Time_O(n)_Space_O(1) | 3 | 71.05 | 0031 |[Next Permutation](src/main/ts/g0001_0100/s0031_next_permutation/solution.ts)| Medium | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0028 |[Implement strStr()](src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching, Programming_Skills_II_Day_1, Top_Interview_150_Array/String | 0 | 100.00 +| 0027 |[Remove Element](src/main/ts/g0001_0100/s0027_remove_element/solution.ts)| Easy | Array, Two_Pointers, Top_Interview_150_Array/String | 0 | 100.00 +| 0026 |[Remove Duplicates from Sorted Array](src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Two_Pointers, Udemy_Two_Pointers, Top_Interview_150_Array/String | 0 | 100.00 | 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_13_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 | 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_12_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Top_Interview_150_Divide_and_Conquer, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 4 | 97.65 @@ -1690,6 +1703,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Algorithm_I_Day_5_Two_Pointers, Level_2_Day_3_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 | 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_1_Array, Algorithm_II_Day_3_Two_Pointers, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 +| 0014 |[Longest Common Prefix](src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Level_2_Day_2_String, Udemy_Strings, Top_Interview_150_Array/String | 0 | 100.00 +| 0013 |[Roman to Integer](src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Math, Top_Interview_150_Array/String | 3 | 94.58 +| 0012 |[Integer to Roman](src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts)| Medium | String, Hash_Table, Math, Top_Interview_150_Array/String | 3 | 93.02 | 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Algorithm_II_Day_4_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 | 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Udemy_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 5 | 90.44 | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math, Udemy_Integers, Top_Interview_150_Math | 3 | 99.14 diff --git a/src/main/ts/g0001_0100/s0012_integer_to_roman/readme.md b/src/main/ts/g0001_0100/s0012_integer_to_roman/readme.md new file mode 100644 index 0000000..456e0cf --- /dev/null +++ b/src/main/ts/g0001_0100/s0012_integer_to_roman/readme.md @@ -0,0 +1,62 @@ +12\. Integer to Roman + +Medium + +Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. + + Symbol Value + I 1 + V 5 + X 10 + L 50 + C 100 + D 500 + M 1000 + +For example, `2` is written as `II` in Roman numeral, just two one's added together. `12` is written as `XII`, which is simply `X + II`. The number `27` is written as `XXVII`, which is `XX + V + II`. + +Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not `IIII`. Instead, the number four is written as `IV`. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as `IX`. There are six instances where subtraction is used: + +* `I` can be placed before `V` (5) and `X` (10) to make 4 and 9. +* `X` can be placed before `L` (50) and `C` (100) to make 40 and 90. +* `C` can be placed before `D` (500) and `M` (1000) to make 400 and 900. + +Given an integer, convert it to a roman numeral. + +**Example 1:** + +**Input:** num = 3 + +**Output:** "III" + +**Example 2:** + +**Input:** num = 4 + +**Output:** "IV" + +**Example 3:** + +**Input:** num = 9 + +**Output:** "IX" + +**Example 4:** + +**Input:** num = 58 + +**Output:** "LVIII" + +**Explanation:** L = 50, V = 5, III = 3. + +**Example 5:** + +**Input:** num = 1994 + +**Output:** "MCMXCIV" + +**Explanation:** M = 1000, CM = 900, XC = 90 and IV = 4. + +**Constraints:** + +* `1 <= num <= 3999` diff --git a/src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts b/src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts new file mode 100644 index 0000000..13e5ea3 --- /dev/null +++ b/src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts @@ -0,0 +1,23 @@ +// #Medium #String #Hash_Table #Math #Top_Interview_150_Array/String +// #2025_03_31_Time_3_ms_(93.02%)_Space_61.86_MB_(54.05%) + +function intToRoman(num: number): string { + const values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]; + const symbols = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]; + + let result = ""; + let i = 0; + + while (num > 0) { + if (num >= values[i]) { + result += symbols[i]; + num -= values[i]; + } else { + i++; + } + } + + return result; +}; + +export { intToRoman } diff --git a/src/main/ts/g0001_0100/s0013_roman_to_integer/readme.md b/src/main/ts/g0001_0100/s0013_roman_to_integer/readme.md new file mode 100644 index 0000000..14bbde8 --- /dev/null +++ b/src/main/ts/g0001_0100/s0013_roman_to_integer/readme.md @@ -0,0 +1,64 @@ +13\. Roman to Integer + +Easy + +Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. + + Symbol Value + I 1 + V 5 + X 10 + L 50 + C 100 + D 500 + M 1000 + +For example, `2` is written as `II` in Roman numeral, just two one's added together. `12` is written as `XII`, which is simply `X + II`. The number `27` is written as `XXVII`, which is `XX + V + II`. + +Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not `IIII`. Instead, the number four is written as `IV`. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as `IX`. There are six instances where subtraction is used: + +* `I` can be placed before `V` (5) and `X` (10) to make 4 and 9. +* `X` can be placed before `L` (50) and `C` (100) to make 40 and 90. +* `C` can be placed before `D` (500) and `M` (1000) to make 400 and 900. + +Given a roman numeral, convert it to an integer. + +**Example 1:** + +**Input:** s = "III" + +**Output:** 3 + +**Example 2:** + +**Input:** s = "IV" + +**Output:** 4 + +**Example 3:** + +**Input:** s = "IX" + +**Output:** 9 + +**Example 4:** + +**Input:** s = "LVIII" + +**Output:** 58 + +**Explanation:** L = 50, V= 5, III = 3. + +**Example 5:** + +**Input:** s = "MCMXCIV" + +**Output:** 1994 + +**Explanation:** M = 1000, CM = 900, XC = 90 and IV = 4. + +**Constraints:** + +* `1 <= s.length <= 15` +* `s` contains only the characters `('I', 'V', 'X', 'L', 'C', 'D', 'M')`. +* It is **guaranteed** that `s` is a valid roman numeral in the range `[1, 3999]`. diff --git a/src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts b/src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts new file mode 100644 index 0000000..9bfc66c --- /dev/null +++ b/src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts @@ -0,0 +1,51 @@ +// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Math +// #Top_Interview_150_Array/String #2025_03_31_Time_3_ms_(94.58%)_Space_61.52_MB_(51.93%) + +function romanToInt(s: string): number { + let x = 0; + let y: string; + + for (let i = 0; i < s.length; i++) { + y = s.charAt(i); + switch (y) { + case 'I': + x = getX(s, x, i, 1, 'V', 'X'); + break; + case 'V': + x += 5; + break; + case 'X': + x = getX(s, x, i, 10, 'L', 'C'); + break; + case 'L': + x += 50; + break; + case 'C': + x = getX(s, x, i, 100, 'D', 'M'); + break; + case 'D': + x += 500; + break; + case 'M': + x += 1000; + break; + default: + break; + } + } + return x; +} + +function getX(s: string, x: number, i: number, i2: number, v: string, x2: string): number { + if (i + 1 === s.length) { + x += i2; + } else if (s.charAt(i + 1) === v || s.charAt(i + 1) === x2) { + x -= i2; + } else { + x += i2; + } + return x; +} + + +export { romanToInt } diff --git a/src/main/ts/g0001_0100/s0014_longest_common_prefix/readme.md b/src/main/ts/g0001_0100/s0014_longest_common_prefix/readme.md new file mode 100644 index 0000000..3f23b8c --- /dev/null +++ b/src/main/ts/g0001_0100/s0014_longest_common_prefix/readme.md @@ -0,0 +1,27 @@ +14\. Longest Common Prefix + +Easy + +Write a function to find the longest common prefix string amongst an array of strings. + +If there is no common prefix, return an empty string `""`. + +**Example 1:** + +**Input:** strs = ["flower","flow","flight"] + +**Output:** "fl" + +**Example 2:** + +**Input:** strs = ["dog","racecar","car"] + +**Output:** "" + +**Explanation:** There is no common prefix among the input strings. + +**Constraints:** + +* `1 <= strs.length <= 200` +* `0 <= strs[i].length <= 200` +* `strs[i]` consists of only lower-case English letters. \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts b/src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts new file mode 100644 index 0000000..42b1bb6 --- /dev/null +++ b/src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts @@ -0,0 +1,29 @@ +// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #String #Level_2_Day_2_String +// #Udemy_Strings #Top_Interview_150_Array/String +// #2025_03_31_Time_0_ms_(100.00%)_Space_54.23_MB_(65.24%) + +function longestCommonPrefix(strs: string[]): string { + if (strs.length < 1) { + return ""; + } + if (strs.length === 1) { + return strs[0]; + } + let temp = strs[0]; + let i = 1; + let cur: string; + while (temp.length > 0 && i < strs.length) { + if (temp.length > strs[i].length) { + temp = temp.substring(0, strs[i].length); + } + cur = strs[i].substring(0, temp.length); + if (cur !== temp) { + temp = temp.substring(0, temp.length - 1); + } else { + i++; + } + } + return temp; +} + +export { longestCommonPrefix } diff --git a/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/readme.md b/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/readme.md new file mode 100644 index 0000000..b4e776e --- /dev/null +++ b/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/readme.md @@ -0,0 +1,49 @@ +26\. Remove Duplicates from Sorted Array + +Easy + +Given an integer array `nums` sorted in **non-decreasing order**, remove the duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears only **once**. The **relative order** of the elements should be kept the **same**. + +Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the **first part** of the array `nums`. More formally, if there are `k` elements after removing the duplicates, then the first `k` elements of `nums` should hold the final result. It does not matter what you leave beyond the first `k` elements. + +Return `k` _after placing the final result in the first_ `k` _slots of_ `nums`. + +Do **not** allocate extra space for another array. You must do this by **modifying the input array [in-place](https://en.wikipedia.org/wiki/In-place_algorithm)** with O(1) extra memory. + +**Custom Judge:** + +The judge will test your solution with the following code: + + int[] nums = [...]; // Input array + int[] expectedNums = [...]; // The expected answer with correct length + + int k = removeDuplicates(nums); // Calls your implementation + + assert k == expectedNums.length; + for (int i = 0; i < k; i++) { + assert nums[i] == expectedNums[i]; + } + +If all assertions pass, then your solution will be **accepted**. + +**Example 1:** + +**Input:** nums = [1,1,2] + +**Output:** 2, nums = [1,2,\_] + +**Explanation:** Your function should return k = 2, with the first two elements of nums being 1 and 2 respectively. It does not matter what you leave beyond the returned k (hence they are underscores). + +**Example 2:** + +**Input:** nums = [0,0,1,1,1,2,2,3,3,4] + +**Output:** 5, nums = [0,1,2,3,4,\_,\_,\_,\_,\_] + +**Explanation:** Your function should return k = 5, with the first five elements of nums being 0, 1, 2, 3, and 4 respectively. It does not matter what you leave beyond the returned k (hence they are underscores). + +**Constraints:** + +* 0 <= nums.length <= 3 * 104 +* `-100 <= nums[i] <= 100` +* `nums` is sorted in **non-decreasing** order. \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts b/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts new file mode 100644 index 0000000..35890ea --- /dev/null +++ b/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts @@ -0,0 +1,21 @@ +// #Easy #Top_Interview_Questions #Array #Two_Pointers #Udemy_Two_Pointers +// #Top_Interview_150_Array/String #2025_03_31_Time_0_ms_(100.00%)_Space_58.42_MB_(57.44%) + +function removeDuplicates(nums: number[]): number { + let n = nums.length; + let i = 0; + let j = 1; + if (n <= 1) { + return n; + } + while (j <= n - 1) { + if (nums[i] !== nums[j]) { + nums[i + 1] = nums[j]; + i++; + } + j++; + } + return i + 1; +} + +export { removeDuplicates } diff --git a/src/main/ts/g0001_0100/s0027_remove_element/readme.md b/src/main/ts/g0001_0100/s0027_remove_element/readme.md new file mode 100644 index 0000000..027b058 --- /dev/null +++ b/src/main/ts/g0001_0100/s0027_remove_element/readme.md @@ -0,0 +1,52 @@ +27\. Remove Element + +Easy + +Given an integer array `nums` and an integer `val`, remove all occurrences of `val` in `nums` [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm). The relative order of the elements may be changed. + +Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the **first part** of the array `nums`. More formally, if there are `k` elements after removing the duplicates, then the first `k` elements of `nums` should hold the final result. It does not matter what you leave beyond the first `k` elements. + +Return `k` _after placing the final result in the first_ `k` _slots of_ `nums`. + +Do **not** allocate extra space for another array. You must do this by **modifying the input array [in-place](https://en.wikipedia.org/wiki/In-place_algorithm)** with O(1) extra memory. + +**Custom Judge:** + +The judge will test your solution with the following code: + + int[] nums = [...]; // Input array + int val = ...; // Value to remove + int[] expectedNums = [...]; // The expected answer with correct length. + // It is sorted with no values equaling val. + + int k = removeElement(nums, val); // Calls your implementation + + assert k == expectedNums.length; + sort(nums, 0, k); // Sort the first k elements of nums + for (int i = 0; i < actualLength; i++) { + assert nums[i] == expectedNums[i]; + } + +If all assertions pass, then your solution will be **accepted**. + +**Example 1:** + +**Input:** nums = [3,2,2,3], val = 3 + +**Output:** 2, nums = [2,2,\_,\_] + +**Explanation:** Your function should return k = 2, with the first two elements of nums being 2. It does not matter what you leave beyond the returned k (hence they are underscores). + +**Example 2:** + +**Input:** nums = [0,1,2,2,3,0,4,2], val = 2 + +**Output:** 5, nums = [0,1,4,0,3,\_,\_,\_] + +**Explanation:** Your function should return k = 5, with the first five elements of nums containing 0, 0, 1, 3, and 4. Note that the five elements can be returned in any order. It does not matter what you leave beyond the returned k (hence they are underscores). + +**Constraints:** + +* `0 <= nums.length <= 100` +* `0 <= nums[i] <= 50` +* `0 <= val <= 100` \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0027_remove_element/solution.ts b/src/main/ts/g0001_0100/s0027_remove_element/solution.ts new file mode 100644 index 0000000..6f91553 --- /dev/null +++ b/src/main/ts/g0001_0100/s0027_remove_element/solution.ts @@ -0,0 +1,34 @@ +// #Easy #Array #Two_Pointers #Top_Interview_150_Array/String +// #2025_03_31_Time_0_ms_(100.00%)_Space_56.09_MB_(20.94%) + +function removeElement(nums: number[], val: number): number { + if (!nums || nums.length === 0) { + return 0; + } + let len = nums.length; + let j = len - 1; + let occurTimes = 0; + for (let i = 0; i < len; i++) { + if (nums[i] === val) { + occurTimes++; + if (j === i) { + return len - occurTimes; + } + while (nums[j] === val) { + j--; + occurTimes++; + if (j === i) { + return len - occurTimes; + } + } + nums[i] = nums[j]; + j--; + } + if (i === j) { + return len - occurTimes; + } + } + return len - occurTimes; +} + +export { removeElement } diff --git a/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/readme.md b/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/readme.md new file mode 100644 index 0000000..098bd24 --- /dev/null +++ b/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/readme.md @@ -0,0 +1,36 @@ +28\. Implement strStr() + +Easy + +Implement [strStr()](http://www.cplusplus.com/reference/cstring/strstr/). + +Return the index of the first occurrence of needle in haystack, or `-1` if `needle` is not part of `haystack`. + +**Clarification:** + +What should we return when `needle` is an empty string? This is a great question to ask during an interview. + +For the purpose of this problem, we will return 0 when `needle` is an empty string. This is consistent to C's [strstr()](http://www.cplusplus.com/reference/cstring/strstr/) and Java's [indexOf()](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#indexOf(java.lang.String)). + +**Example 1:** + +**Input:** haystack = "hello", needle = "ll" + +**Output:** 2 + +**Example 2:** + +**Input:** haystack = "aaaaa", needle = "bba" + +**Output:** -1 + +**Example 3:** + +**Input:** haystack = "", needle = "" + +**Output:** 0 + +**Constraints:** + +* 0 <= haystack.length, needle.length <= 5 * 104 +* `haystack` and `needle` consist of only lower-case English characters. \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts b/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts new file mode 100644 index 0000000..e966944 --- /dev/null +++ b/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts @@ -0,0 +1,19 @@ +// #Easy #Top_Interview_Questions #String #Two_Pointers #String_Matching +// #Programming_Skills_II_Day_1 #Top_Interview_150_Array/String +// #2025_03_31_Time_0_ms_(100.00%)_Space_55.44_MB_(48.55%) + +function strStr(haystack: string, needle: string): number { + if (needle.length === 0) { + return 0; + } + let m = haystack.length; + let n = needle.length; + for (let start = 0; start <= m - n; start++) { + if (haystack.substring(start, start + n) === needle) { + return start; + } + } + return -1; +} + +export { strStr } diff --git a/src/test/ts/g0001_0100/s0012_integer_to_roman/solution.test.ts b/src/test/ts/g0001_0100/s0012_integer_to_roman/solution.test.ts new file mode 100644 index 0000000..e489986 --- /dev/null +++ b/src/test/ts/g0001_0100/s0012_integer_to_roman/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { intToRoman } from 'src/main/ts/g0001_0100/s0012_integer_to_roman/solution' +import { expect, test } from 'vitest' + +test('intToRoman', () => { + expect(intToRoman(3749)).toEqual('MMMDCCXLIX') +}) + +test('intToRoman2', () => { + expect(intToRoman(58)).toEqual('LVIII') +}) + +test('intToRoman3', () => { + expect(intToRoman(1994)).toEqual('MCMXCIV') +}) diff --git a/src/test/ts/g0001_0100/s0013_roman_to_integer/solution.test.ts b/src/test/ts/g0001_0100/s0013_roman_to_integer/solution.test.ts new file mode 100644 index 0000000..fc05b04 --- /dev/null +++ b/src/test/ts/g0001_0100/s0013_roman_to_integer/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { romanToInt } from 'src/main/ts/g0001_0100/s0013_roman_to_integer/solution' +import { expect, test } from 'vitest' + +test('romanToInt', () => { + expect(romanToInt('III')).toEqual(3) +}) + +test('romanToInt2', () => { + expect(romanToInt('LVIII')).toEqual(58) +}) + +test('romanToInt3', () => { + expect(romanToInt('MCMXCIV')).toEqual(1994) +}) diff --git a/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts b/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts new file mode 100644 index 0000000..6754c20 --- /dev/null +++ b/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { longestCommonPrefix } from 'src/main/ts/g0001_0100/s0014_longest_common_prefix/solution' +import { expect, test } from 'vitest' + +test('longestCommonPrefix', () => { + expect(longestCommonPrefix(['flower','flow','flight'])).toEqual('fl') +}) + +test('longestCommonPrefix2', () => { + expect(longestCommonPrefix(['dog','racecar','car'])).toEqual('') +}) diff --git a/src/test/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.test.ts b/src/test/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.test.ts new file mode 100644 index 0000000..24c5a76 --- /dev/null +++ b/src/test/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { removeDuplicates } from 'src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution' +import { expect, test } from 'vitest' + +test('removeDuplicates', () => { + expect(removeDuplicates([1,1,2])).toEqual(2) +}) + +test('removeDuplicates2', () => { + expect(removeDuplicates([0,0,1,1,1,2,2,3,3,4])).toEqual(5) +}) diff --git a/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts b/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts new file mode 100644 index 0000000..835d475 --- /dev/null +++ b/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { removeElement } from 'src/main/ts/g0001_0100/s0027_remove_element/solution' +import { expect, test } from 'vitest' + +test('removeElement', () => { + expect(removeElement([3,2,2,3], 3)).toEqual(2) +}) + +test('removeElement2', () => { + expect(removeElement([0,1,2,2,3,0,4,2], 2)).toEqual(5) +}) diff --git a/src/test/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.test.ts b/src/test/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.test.ts new file mode 100644 index 0000000..757091c --- /dev/null +++ b/src/test/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { strStr } from 'src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution' +import { expect, test } from 'vitest' + +test('strStr', () => { + expect(strStr("sadbutsad", "sad")).toEqual(0) +}) + +test('strStr2', () => { + expect(strStr("leetcode", "leeto")).toEqual(-1) +}) From 163bb274cb049cc06c2ab762e5bf3057ecf56b9b Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Mon, 31 Mar 2025 19:33:53 +0300 Subject: [PATCH 17/49] Improved tasks 12-28 --- .../s0012_integer_to_roman/solution.ts | 21 ++++---- .../s0013_roman_to_integer/solution.ts | 48 +++++++++---------- .../s0014_longest_common_prefix/solution.ts | 20 ++++---- .../solution.ts | 16 +++---- .../s0027_remove_element/solution.ts | 26 +++++----- .../solution.ts | 10 ++-- .../solution.test.ts | 8 ++++ .../s0027_remove_element/solution.test.ts | 19 ++++++++ .../solution.test.ts | 8 +++- 9 files changed, 101 insertions(+), 75 deletions(-) diff --git a/src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts b/src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts index 13e5ea3..b6c28de 100644 --- a/src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts +++ b/src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts @@ -2,22 +2,19 @@ // #2025_03_31_Time_3_ms_(93.02%)_Space_61.86_MB_(54.05%) function intToRoman(num: number): string { - const values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]; - const symbols = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]; - - let result = ""; - let i = 0; - + const values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] + const symbols = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'] + let result = '' + let i = 0 while (num > 0) { if (num >= values[i]) { - result += symbols[i]; - num -= values[i]; + result += symbols[i] + num -= values[i] } else { - i++; + i++ } } - - return result; -}; + return result +} export { intToRoman } diff --git a/src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts b/src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts index 9bfc66c..827a80d 100644 --- a/src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts +++ b/src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts @@ -2,50 +2,48 @@ // #Top_Interview_150_Array/String #2025_03_31_Time_3_ms_(94.58%)_Space_61.52_MB_(51.93%) function romanToInt(s: string): number { - let x = 0; - let y: string; - + let x = 0 + let y: string for (let i = 0; i < s.length; i++) { - y = s.charAt(i); + y = s.charAt(i) switch (y) { case 'I': - x = getX(s, x, i, 1, 'V', 'X'); - break; + x = getX(s, x, i, 1, 'V', 'X') + break case 'V': - x += 5; - break; + x += 5 + break case 'X': - x = getX(s, x, i, 10, 'L', 'C'); - break; + x = getX(s, x, i, 10, 'L', 'C') + break case 'L': - x += 50; - break; + x += 50 + break case 'C': - x = getX(s, x, i, 100, 'D', 'M'); - break; + x = getX(s, x, i, 100, 'D', 'M') + break case 'D': - x += 500; - break; + x += 500 + break case 'M': - x += 1000; - break; + x += 1000 + break default: - break; + break } } - return x; + return x } function getX(s: string, x: number, i: number, i2: number, v: string, x2: string): number { if (i + 1 === s.length) { - x += i2; + x += i2 } else if (s.charAt(i + 1) === v || s.charAt(i + 1) === x2) { - x -= i2; + x -= i2 } else { - x += i2; + x += i2 } - return x; + return x } - export { romanToInt } diff --git a/src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts b/src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts index 42b1bb6..4747f5b 100644 --- a/src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts +++ b/src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts @@ -4,26 +4,26 @@ function longestCommonPrefix(strs: string[]): string { if (strs.length < 1) { - return ""; + return '' } if (strs.length === 1) { - return strs[0]; + return strs[0] } - let temp = strs[0]; - let i = 1; - let cur: string; + let temp = strs[0] + let i = 1 + let cur: string while (temp.length > 0 && i < strs.length) { if (temp.length > strs[i].length) { - temp = temp.substring(0, strs[i].length); + temp = temp.substring(0, strs[i].length) } - cur = strs[i].substring(0, temp.length); + cur = strs[i].substring(0, temp.length) if (cur !== temp) { - temp = temp.substring(0, temp.length - 1); + temp = temp.substring(0, temp.length - 1) } else { - i++; + i++ } } - return temp; + return temp } export { longestCommonPrefix } diff --git a/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts b/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts index 35890ea..334a8b6 100644 --- a/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts +++ b/src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts @@ -2,20 +2,20 @@ // #Top_Interview_150_Array/String #2025_03_31_Time_0_ms_(100.00%)_Space_58.42_MB_(57.44%) function removeDuplicates(nums: number[]): number { - let n = nums.length; - let i = 0; - let j = 1; + let n = nums.length + let i = 0 + let j = 1 if (n <= 1) { - return n; + return n } while (j <= n - 1) { if (nums[i] !== nums[j]) { - nums[i + 1] = nums[j]; - i++; + nums[i + 1] = nums[j] + i++ } - j++; + j++ } - return i + 1; + return i + 1 } export { removeDuplicates } diff --git a/src/main/ts/g0001_0100/s0027_remove_element/solution.ts b/src/main/ts/g0001_0100/s0027_remove_element/solution.ts index 6f91553..a6a348b 100644 --- a/src/main/ts/g0001_0100/s0027_remove_element/solution.ts +++ b/src/main/ts/g0001_0100/s0027_remove_element/solution.ts @@ -3,32 +3,32 @@ function removeElement(nums: number[], val: number): number { if (!nums || nums.length === 0) { - return 0; + return 0 } - let len = nums.length; - let j = len - 1; - let occurTimes = 0; + let len = nums.length + let j = len - 1 + let occurTimes = 0 for (let i = 0; i < len; i++) { if (nums[i] === val) { - occurTimes++; + occurTimes++ if (j === i) { - return len - occurTimes; + return len - occurTimes } while (nums[j] === val) { - j--; - occurTimes++; + j-- + occurTimes++ if (j === i) { - return len - occurTimes; + return len - occurTimes } } - nums[i] = nums[j]; - j--; + nums[i] = nums[j] + j-- } if (i === j) { - return len - occurTimes; + return len - occurTimes } } - return len - occurTimes; + return len - occurTimes } export { removeElement } diff --git a/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts b/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts index e966944..83414ba 100644 --- a/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts +++ b/src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts @@ -4,16 +4,16 @@ function strStr(haystack: string, needle: string): number { if (needle.length === 0) { - return 0; + return 0 } - let m = haystack.length; - let n = needle.length; + let m = haystack.length + let n = needle.length for (let start = 0; start <= m - n; start++) { if (haystack.substring(start, start + n) === needle) { - return start; + return start } } - return -1; + return -1 } export { strStr } diff --git a/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts b/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts index 6754c20..6e12553 100644 --- a/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts +++ b/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts @@ -9,3 +9,11 @@ test('longestCommonPrefix', () => { test('longestCommonPrefix2', () => { expect(longestCommonPrefix(['dog','racecar','car'])).toEqual('') }) + +test('longestCommonPrefix3', () => { + expect(longestCommonPrefix([])).toEqual('') +}) + +test('longestCommonPrefix4', () => { + expect(longestCommonPrefix(['dog'])).toEqual('dog') +}) diff --git a/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts b/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts index 835d475..fdf08c6 100644 --- a/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts +++ b/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts @@ -9,3 +9,22 @@ test('removeElement', () => { test('removeElement2', () => { expect(removeElement([0,1,2,2,3,0,4,2], 2)).toEqual(5) }) + +test('removeElement3', () => { + const nums: number[] = [] + const val = 1 + expect(removeElement(nums, val)).toEqual(0) +}) + +test('removeElement4', () => { + const nums = [1, 1, 1, 1] + const val = 1 + expect(removeElement(nums, val)).toEqual(0) +}) + +test('removeElement5', () => { + const nums = [4, 5] + const val = 4 + expect(removeElement(nums, val)).toEqual(1) + expect(nums[0]).toEqual(5) +}) diff --git a/src/test/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.test.ts b/src/test/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.test.ts index 757091c..1d1bbd4 100644 --- a/src/test/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.test.ts +++ b/src/test/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.test.ts @@ -3,9 +3,13 @@ import { strStr } from 'src/main/ts/g0001_0100/s0028_find_the_index_of_the_first import { expect, test } from 'vitest' test('strStr', () => { - expect(strStr("sadbutsad", "sad")).toEqual(0) + expect(strStr('sadbutsad', 'sad')).toEqual(0) }) test('strStr2', () => { - expect(strStr("leetcode", "leeto")).toEqual(-1) + expect(strStr('leetcode', 'leeto')).toEqual(-1) +}) + +test('strStr3', () => { + expect(strStr('leetcode', '')).toEqual(0) }) From b98c9e4f4b8337991a6f6bb680720d08f5792a51 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Mon, 31 Mar 2025 19:41:23 +0300 Subject: [PATCH 18/49] Improved sonar plugin --- .github/workflows/node.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 5e62cf3..ff1bfe1 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -34,7 +34,7 @@ jobs: ls -al coverage - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master + uses: sonarsource/sonarqube-scan-action@v4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: 1ebdc4b127391a8acbc3420eb585961e4e0846de From 0f6735ab9d1d50023451616a0fdbfea222b8efc6 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Tue, 1 Apr 2025 21:59:33 +0700 Subject: [PATCH 19/49] Added tasks 30-58 --- README.md | 275 +++++++++--------- .../readme.md | 35 +++ .../solution.ts | 48 +++ .../g0001_0100/s0036_valid_sudoku/readme.md | 58 ++++ .../g0001_0100/s0036_valid_sudoku/solution.ts | 29 ++ src/main/ts/g0001_0100/s0050_powx_n/readme.md | 31 ++ .../ts/g0001_0100/s0050_powx_n/solution.ts | 22 ++ .../ts/g0001_0100/s0052_n_queens_ii/readme.md | 27 ++ .../g0001_0100/s0052_n_queens_ii/solution.ts | 22 ++ .../g0001_0100/s0054_spiral_matrix/readme.md | 28 ++ .../s0054_spiral_matrix/solution.ts | 36 +++ .../solution.test.ts | 15 + .../s0036_valid_sudoku/solution.test.ts | 27 ++ .../g0001_0100/s0050_powx_n/solution.test.ts | 15 + .../s0052_n_queens_ii/solution.test.ts | 11 + .../s0054_spiral_matrix/solution.test.ts | 11 + 16 files changed, 560 insertions(+), 130 deletions(-) create mode 100644 src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/readme.md create mode 100644 src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts create mode 100644 src/main/ts/g0001_0100/s0036_valid_sudoku/readme.md create mode 100644 src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts create mode 100644 src/main/ts/g0001_0100/s0050_powx_n/readme.md create mode 100644 src/main/ts/g0001_0100/s0050_powx_n/solution.ts create mode 100644 src/main/ts/g0001_0100/s0052_n_queens_ii/readme.md create mode 100644 src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts create mode 100644 src/main/ts/g0001_0100/s0054_spiral_matrix/readme.md create mode 100644 src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts create mode 100644 src/test/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0036_valid_sudoku/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0050_powx_n/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0052_n_queens_ii/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0054_spiral_matrix/solution.test.ts diff --git a/README.md b/README.md index f9bc867..f48ae7c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) ## -* [Algorithm II](#algorithm-ii) * [Binary Search I](#binary-search-i) * [Binary Search II](#binary-search-ii) * [Dynamic Programming I](#dynamic-programming-i) @@ -27,135 +26,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. * [Data Structure I](#data-structure-i) * [Data Structure II](#data-structure-ii) * [Algorithm I](#algorithm-i) - -### Algorithm II - -#### Day 1 Binary Search - -| | | | | | -|-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 - -#### Day 2 Binary Search - -| | | | | | -|-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 - -#### Day 3 Two Pointers - -| | | | | | -|-|-|-|-|-|- -| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 - -#### Day 4 Two Pointers - -| | | | | | -|-|-|-|-|-|- -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 - -#### Day 5 Sliding Window - -| | | | | | -|-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 - -#### Day 6 Breadth First Search Depth First Search - -| | | | | | -|-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 - -#### Day 7 Breadth First Search Depth First Search - -| | | | | | -|-|-|-|-|-|- - -#### Day 8 Breadth First Search Depth First Search - -| | | | | | -|-|-|-|-|-|- - -#### Day 9 Recursion Backtracking - -| | | | | | -|-|-|-|-|-|- -| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 - -#### Day 10 Recursion Backtracking - -| | | | | | -|-|-|-|-|-|- -| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 - -#### Day 11 Recursion Backtracking - -| | | | | | -|-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 -| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 -| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 243 | 85.30 - -#### Day 12 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 - -#### Day 13 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 - -#### Day 14 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 - -#### Day 15 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 - -#### Day 16 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 - -#### Day 17 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 - -#### Day 18 Dynamic Programming - -| | | | | | -|-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 -| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 - -#### Day 19 Bit Manipulation - -| | | | | | -|-|-|-|-|-|- - -#### Day 20 Others - -| | | | | | -|-|-|-|-|-|- - -#### Day 21 Others - -| | | | | | -|-|-|-|-|-|- +* [Algorithm II](#algorithm-ii) ### Binary Search I @@ -562,6 +433,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0054 |[Spiral Matrix](src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 #### Day 9 @@ -848,6 +720,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0054 |[Spiral Matrix](src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 #### Day 2 String @@ -975,6 +848,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 53 | 83.14 | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 +| 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 #### Udemy Strings @@ -1033,6 +907,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 0054 |[Spiral Matrix](src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 | 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 | 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 4 | 50.63 | 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 @@ -1147,12 +1022,15 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 +| 0030 |[Substring with Concatenation of All Words](src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts)| Hard | String, Hash_Table, Sliding_Window | 13 | 97.44 | 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 20 | 90.35 #### Top Interview 150 Matrix | | | | | | |-|-|-|-|-|- +| 0036 |[Valid Sudoku](src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix | 1 | 99.60 +| 0054 |[Spiral Matrix](src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 | 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 | 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 4 | 50.63 @@ -1239,6 +1117,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 | 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 +| 0052 |[N-Queens II](src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts)| Hard | Backtracking | 1 | 96.89 | 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 | 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 243 | 85.30 @@ -1284,6 +1163,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 +| 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 #### Top Interview 150 1D DP @@ -1333,6 +1213,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0036 |[Valid Sudoku](src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix | 1 | 99.60 | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 #### Day 6 String @@ -1603,6 +1484,135 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +### Algorithm II + +#### Day 1 Binary Search + +| | | | | | +|-|-|-|-|-|- +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 + +#### Day 2 Binary Search + +| | | | | | +|-|-|-|-|-|- +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 + +#### Day 3 Two Pointers + +| | | | | | +|-|-|-|-|-|- +| 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 + +#### Day 4 Two Pointers + +| | | | | | +|-|-|-|-|-|- +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 + +#### Day 5 Sliding Window + +| | | | | | +|-|-|-|-|-|- +| 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 + +#### Day 6 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- +| 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 + +#### Day 7 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- + +#### Day 8 Breadth First Search Depth First Search + +| | | | | | +|-|-|-|-|-|- + +#### Day 9 Recursion Backtracking + +| | | | | | +|-|-|-|-|-|- +| 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 + +#### Day 10 Recursion Backtracking + +| | | | | | +|-|-|-|-|-|- +| 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 + +#### Day 11 Recursion Backtracking + +| | | | | | +|-|-|-|-|-|- +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 +| 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 243 | 85.30 + +#### Day 12 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 + +#### Day 13 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 + +#### Day 14 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 + +#### Day 15 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 + +#### Day 16 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 + +#### Day 17 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 + +#### Day 18 Dynamic Programming + +| | | | | | +|-|-|-|-|-|- +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 +| 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 + +#### Day 19 Bit Manipulation + +| | | | | | +|-|-|-|-|-|- + +#### Day 20 Others + +| | | | | | +|-|-|-|-|-|- + +#### Day 21 Others + +| | | | | | +|-|-|-|-|-|- + ## Algorithms | # | Title | Difficulty | Tag | Time, ms | Time, % @@ -1677,8 +1687,11 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_15, Level_1_Day_11_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 | 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Data_Structure_II_Day_2_Array, Level_2_Day_17_Interval, Udemy_2D_Arrays/Matrix, Top_Interview_150_Intervals, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_4, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0054 |[Spiral Matrix](src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation, Programming_Skills_II_Day_8, Level_2_Day_1_Implementation/Simulation, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix | 0 | 100.00 | 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Data_Structure_I_Day_1_Array, Dynamic_Programming_I_Day_5, Udemy_Famous_Algorithm, Top_Interview_150_Kadane's_Algorithm, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0052 |[N-Queens II](src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts)| Hard | Backtracking, Top_Interview_150_Backtracking | 1 | 96.89 | 0051 |[N-Queens](src/main/ts/g0001_0100/s0051_n_queens/solution.ts)| Hard | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(N!)_Space_O(N) | 6 | 95.85 +| 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion, Udemy_Integers, Top_Interview_150_Math | 0 | 100.00 | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Data_Structure_II_Day_8_String, Programming_Skills_II_Day_11, Udemy_Strings, Top_Interview_150_Hashmap, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 | 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Data_Structure_II_Day_3_Array, Programming_Skills_II_Day_7, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 | 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Algorithm_I_Day_11_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 @@ -1686,11 +1699,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Dynamic_Programming_I_Day_9, Udemy_Two_Pointers, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Udemy_Arrays, Big_O_Time_O(n)_Space_O(n) | 1 | 99.11 | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Algorithm_II_Day_10_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 +| 0036 |[Valid Sudoku](src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix, Data_Structure_I_Day_5_Array, Top_Interview_150_Matrix | 1 | 99.60 | 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_I_Day_1_Binary_Search, Binary_Search_I_Day_2, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_5, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_11, Level_2_Day_8_Binary_Search, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0032 |[Longest Valid Parentheses](src/main/ts/g0001_0100/s0032_longest_valid_parentheses/solution.ts)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Stack, Big_O_Time_O(n)_Space_O(1) | 3 | 71.05 | 0031 |[Next Permutation](src/main/ts/g0001_0100/s0031_next_permutation/solution.ts)| Medium | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0030 |[Substring with Concatenation of All Words](src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts)| Hard | String, Hash_Table, Sliding_Window, Top_Interview_150_Sliding_Window | 13 | 97.44 | 0028 |[Implement strStr()](src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching, Programming_Skills_II_Day_1, Top_Interview_150_Array/String | 0 | 100.00 | 0027 |[Remove Element](src/main/ts/g0001_0100/s0027_remove_element/solution.ts)| Easy | Array, Two_Pointers, Top_Interview_150_Array/String | 0 | 100.00 | 0026 |[Remove Duplicates from Sorted Array](src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Two_Pointers, Udemy_Two_Pointers, Top_Interview_150_Array/String | 0 | 100.00 diff --git a/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/readme.md b/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/readme.md new file mode 100644 index 0000000..e4075f4 --- /dev/null +++ b/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/readme.md @@ -0,0 +1,35 @@ +30\. Substring with Concatenation of All Words + +Hard + +You are given a string `s` and an array of strings `words` of **the same length**. Return all starting indices of substring(s) in `s` that is a concatenation of each word in `words` **exactly once**, **in any order**, and **without any intervening characters**. + +You can return the answer in **any order**. + +**Example 1:** + +**Input:** s = "barfoothefoobarman", words = ["foo","bar"] + +**Output:** [0,9] + +**Explanation:** Substrings starting at index 0 and 9 are "barfoo" and "foobar" respectively. The output order does not matter, returning [9,0] is fine too. + +**Example 2:** + +**Input:** s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"] + +**Output:** [] + +**Example 3:** + +**Input:** s = "barfoofoobarthefoobarman", words = ["bar","foo","the"] + +**Output:** [6,9,12] + +**Constraints:** + +* 1 <= s.length <= 104 +* `s` consists of lower-case English letters. +* `1 <= words.length <= 5000` +* `1 <= words[i].length <= 30` +* `words[i]` consists of lower-case English letters. \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts b/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts new file mode 100644 index 0000000..d62f490 --- /dev/null +++ b/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts @@ -0,0 +1,48 @@ +// #Hard #String #Hash_Table #Sliding_Window #Top_Interview_150_Sliding_Window +// #2025_04_01_Time_13_ms_(97.44%)_Space_63.70_MB_(46.03%) + +function findSubstring(s: string, words: string[]): number[] { + let ans: number[] = []; + let n1 = words[0].length; + let n2 = s.length; + let map1 = new Map(); + + for (let ch of words) { + map1.set(ch, (map1.get(ch) ?? 0) + 1); + } + + for (let i = 0; i < n1; i++) { + let left = i; + let j = i; + let c = 0; + let map2 = new Map(); + + while (j + n1 <= n2) { + let word1 = s.substring(j, j + n1); + j += n1; + + if (map1.has(word1)) { + map2.set(word1, (map2.get(word1) ?? 0) + 1); + c++; + + while ((map2.get(word1) ?? 0) > (map1.get(word1) ?? 0)) { + let word2 = s.substring(left, left + n1); + map2.set(word2, (map2.get(word2) ?? 0) - 1); + left += n1; + c--; + } + + if (c === words.length) { + ans.push(left); + } + } else { + map2.clear(); + c = 0; + left = j; + } + } + } + return ans; +} + +export { findSubstring } diff --git a/src/main/ts/g0001_0100/s0036_valid_sudoku/readme.md b/src/main/ts/g0001_0100/s0036_valid_sudoku/readme.md new file mode 100644 index 0000000..db58bb7 --- /dev/null +++ b/src/main/ts/g0001_0100/s0036_valid_sudoku/readme.md @@ -0,0 +1,58 @@ +36\. Valid Sudoku + +Medium + +Determine if a `9 x 9` Sudoku board is valid. Only the filled cells need to be validated **according to the following rules**: + +1. Each row must contain the digits `1-9` without repetition. +2. Each column must contain the digits `1-9` without repetition. +3. Each of the nine `3 x 3` sub-boxes of the grid must contain the digits `1-9` without repetition. + +**Note:** + +* A Sudoku board (partially filled) could be valid but is not necessarily solvable. +* Only the filled cells need to be validated according to the mentioned rules. + +**Example 1:** + +![](https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Sudoku-by-L2G-20050714.svg/250px-Sudoku-by-L2G-20050714.svg.png) + +**Input:** + + board = + [["5","3",".",".","7",".",".",".","."] + ,["6",".",".","1","9","5",".",".","."] + ,[".","9","8",".",".",".",".","6","."] + ,["8",".",".",".","6",".",".",".","3"] + ,["4",".",".","8",".","3",".",".","1"] + ,["7",".",".",".","2",".",".",".","6"] + ,[".","6",".",".",".",".","2","8","."] + ,[".",".",".","4","1","9",".",".","5"] + ,[".",".",".",".","8",".",".","7","9"]] + +**Output:** true + +**Example 2:** + +**Input:** + + board = + [["8","3",".",".","7",".",".",".","."] + ,["6",".",".","1","9","5",".",".","."] + ,[".","9","8",".",".",".",".","6","."] + ,["8",".",".",".","6",".",".",".","3"] + ,["4",".",".","8",".","3",".",".","1"] + ,["7",".",".",".","2",".",".",".","6"] + ,[".","6",".",".",".",".","2","8","."] + ,[".",".",".","4","1","9",".",".","5"] + ,[".",".",".",".","8",".",".","7","9"]] + +**Output:** false + +**Explanation:** Same as Example 1, except with the **5** in the top left corner being modified to **8**. Since there are two 8's in the top left 3x3 sub-box, it is invalid. + +**Constraints:** + +* `board.length == 9` +* `board[i].length == 9` +* `board[i][j]` is a digit `1-9` or `'.'`. \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts b/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts new file mode 100644 index 0000000..42a4760 --- /dev/null +++ b/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts @@ -0,0 +1,29 @@ +// #Medium #Top_Interview_Questions #Array #Hash_Table #Matrix #Data_Structure_I_Day_5_Array +// #Top_Interview_150_Matrix #2025_04_01_Time_1_ms_(99.60%)_Space_58.94_MB_(52.85%) + +function isValidSudoku(board: string[][]): boolean { + let rowSet: number[] = new Array(9).fill(0); + let colSet: number[] = new Array(9).fill(0); + let boxSet: number[] = new Array(9).fill(0); + + for (let i = 0; i < 9; i++) { + for (let j = 0; j < 9; j++) { + if (board[i][j] === '.') { + continue; + } + let val = board[i][j].charCodeAt(0) - '0'.charCodeAt(0); + let boxIndex = Math.floor(i / 3) * 3 + Math.floor(j / 3); + + if ((rowSet[i] & (1 << val)) || (colSet[j] & (1 << val)) || (boxSet[boxIndex] & (1 << val))) { + return false; + } + + rowSet[i] |= 1 << val; + colSet[j] |= 1 << val; + boxSet[boxIndex] |= 1 << val; + } + } + return true; +} + +export { isValidSudoku } diff --git a/src/main/ts/g0001_0100/s0050_powx_n/readme.md b/src/main/ts/g0001_0100/s0050_powx_n/readme.md new file mode 100644 index 0000000..3e93a2f --- /dev/null +++ b/src/main/ts/g0001_0100/s0050_powx_n/readme.md @@ -0,0 +1,31 @@ +50\. Pow(x, n) + +Medium + +Implement [pow(x, n)](http://www.cplusplus.com/reference/valarray/pow/), which calculates `x` raised to the power `n` (i.e., xn). + +**Example 1:** + +**Input:** x = 2.00000, n = 10 + +**Output:** 1024.00000 + +**Example 2:** + +**Input:** x = 2.10000, n = 3 + +**Output:** 9.26100 + +**Example 3:** + +**Input:** x = 2.00000, n = -2 + +**Output:** 0.25000 + +**Explanation:** 2\-2 = 1/22 = 1/4 = 0.25 + +**Constraints:** + +* `-100.0 < x < 100.0` +* -231 <= n <= 231-1 +* -104 <= xn <= 104 \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0050_powx_n/solution.ts b/src/main/ts/g0001_0100/s0050_powx_n/solution.ts new file mode 100644 index 0000000..66ab82b --- /dev/null +++ b/src/main/ts/g0001_0100/s0050_powx_n/solution.ts @@ -0,0 +1,22 @@ +// #Medium #Top_Interview_Questions #Math #Recursion #Udemy_Integers #Top_Interview_150_Math +// #2025_04_01_Time_0_ms_(100.00%)_Space_57.31_MB_(7.22%) + +function myPow(x: number, n: number): number { + let nn = BigInt(n); + let res = 1.0; + if (n < 0) { + nn = -nn; + } + while (nn > 0) { + if (nn % 2n === 1n) { + nn--; + res *= x; + } else { + x *= x; + nn /= 2n; + } + } + return n < 0 ? 1.0 / res : res; +} + +export { myPow } diff --git a/src/main/ts/g0001_0100/s0052_n_queens_ii/readme.md b/src/main/ts/g0001_0100/s0052_n_queens_ii/readme.md new file mode 100644 index 0000000..946096c --- /dev/null +++ b/src/main/ts/g0001_0100/s0052_n_queens_ii/readme.md @@ -0,0 +1,27 @@ +52\. N-Queens II + +Hard + +The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other. + +Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/11/13/queens.jpg) + +**Input:** n = 4 + +**Output:** 2 + +**Explanation:** There are two distinct solutions to the 4-queens puzzle as shown. + +**Example 2:** + +**Input:** n = 1 + +**Output:** 1 + +**Constraints:** + +* `1 <= n <= 9` \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts b/src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts new file mode 100644 index 0000000..0bf35b2 --- /dev/null +++ b/src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts @@ -0,0 +1,22 @@ +// #Hard #Backtracking #Top_Interview_150_Backtracking +// #2025_04_01_Time_1_ms_(96.89%)_Space_56.94_MB_(52.17%) + +function totalNQueens(n: number): number { + function solve(r: number, cols: boolean[], diag: boolean[], antiDiag: boolean[]): number { + if (r === n) { + return 1; + } + let count = 0; + for (let c = 0; c < n; c++) { + if (!cols[c] && !diag[r + c] && !antiDiag[r - c + n - 1]) { + cols[c] = diag[r + c] = antiDiag[r - c + n - 1] = true; + count += solve(r + 1, cols, diag, antiDiag); + cols[c] = diag[r + c] = antiDiag[r - c + n - 1] = false; + } + } + return count; + } + return solve(0, new Array(n).fill(false), new Array(2 * n - 1).fill(false), new Array(2 * n - 1).fill(false)); +} + +export { totalNQueens } diff --git a/src/main/ts/g0001_0100/s0054_spiral_matrix/readme.md b/src/main/ts/g0001_0100/s0054_spiral_matrix/readme.md new file mode 100644 index 0000000..75abbda --- /dev/null +++ b/src/main/ts/g0001_0100/s0054_spiral_matrix/readme.md @@ -0,0 +1,28 @@ +54\. Spiral Matrix + +Medium + +Given an `m x n` `matrix`, return _all elements of the_ `matrix` _in spiral order_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/11/13/spiral1.jpg) + +**Input:** matrix = [[1,2,3],[4,5,6],[7,8,9]] + +**Output:** [1,2,3,6,9,8,7,4,5] + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2020/11/13/spiral.jpg) + +**Input:** matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] + +**Output:** [1,2,3,4,8,12,11,10,9,5,6,7] + +**Constraints:** + +* `m == matrix.length` +* `n == matrix[i].length` +* `1 <= m, n <= 10` +* `-100 <= matrix[i][j] <= 100` \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts b/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts new file mode 100644 index 0000000..a1b56f0 --- /dev/null +++ b/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts @@ -0,0 +1,36 @@ +// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Matrix #Simulation +// #Programming_Skills_II_Day_8 #Level_2_Day_1_Implementation/Simulation #Udemy_2D_Arrays/Matrix +// #Top_Interview_150_Matrix #2025_04_01_Time_0_ms_(100.00%)_Space_55.71_MB_(30.13%) + +function spiralOrder(matrix: number[][]): number[] { + const result: number[] = []; + let r = 0, c = 0; + let bigR = matrix.length - 1; + let bigC = matrix[0].length - 1; + + while (r <= bigR && c <= bigC) { + for (let i = c; i <= bigC; i++) { + result.push(matrix[r][i]); + } + r++; + + for (let i = r; i <= bigR; i++) { + result.push(matrix[i][bigC]); + } + bigC--; + + for (let i = bigC; i >= c && r <= bigR; i--) { + result.push(matrix[bigR][i]); + } + bigR--; + + for (let i = bigR; i >= r && c <= bigC; i--) { + result.push(matrix[i][c]); + } + c++; + } + + return result; +} + +export { spiralOrder } diff --git a/src/test/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.test.ts b/src/test/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.test.ts new file mode 100644 index 0000000..4c4fe7d --- /dev/null +++ b/src/test/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { findSubstring } from 'src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution' +import { expect, test } from 'vitest' + +test('findSubstring', () => { + expect(findSubstring('barfoothefoobarman', ['foo','bar'])).toEqual([0,9]) +}) + +test('findSubstring2', () => { + expect(findSubstring('wordgoodgoodgoodbestword', ['word','good','best','word'])).toEqual([]) +}) + +test('findSubstring3', () => { + expect(findSubstring('barfoofoobarthefoobarman', ['bar','foo','the'])).toEqual([6,9,12]) +}) diff --git a/src/test/ts/g0001_0100/s0036_valid_sudoku/solution.test.ts b/src/test/ts/g0001_0100/s0036_valid_sudoku/solution.test.ts new file mode 100644 index 0000000..db4ff72 --- /dev/null +++ b/src/test/ts/g0001_0100/s0036_valid_sudoku/solution.test.ts @@ -0,0 +1,27 @@ +// tslint:disable:no-magic-numbers +import { isValidSudoku } from 'src/main/ts/g0001_0100/s0036_valid_sudoku/solution' +import { expect, test } from 'vitest' + +test('isValidSudoku', () => { + expect(isValidSudoku([['5','3','.','.','7','.','.','.','.'] + ,['6','.','.','1','9','5','.','.','.'] + ,['.','9','8','.','.','.','.','6','.'] + ,['8','.','.','.','6','.','.','.','3'] + ,['4','.','.','8','.','3','.','.','1'] + ,['7','.','.','.','2','.','.','.','6'] + ,['.','6','.','.','.','.','2','8','.'] + ,['.','.','.','4','1','9','.','.','5'] + ,['.','.','.','.','8','.','.','7','9']])).toEqual(true) +}) + +test('isValidSudoku2', () => { + expect(isValidSudoku([['8','3','.','.','7','.','.','.','.'] + ,['6','.','.','1','9','5','.','.','.'] + ,['.','9','8','.','.','.','.','6','.'] + ,['8','.','.','.','6','.','.','.','3'] + ,['4','.','.','8','.','3','.','.','1'] + ,['7','.','.','.','2','.','.','.','6'] + ,['.','6','.','.','.','.','2','8','.'] + ,['.','.','.','4','1','9','.','.','5'] + ,['.','.','.','.','8','.','.','7','9']])).toEqual(false) +}) diff --git a/src/test/ts/g0001_0100/s0050_powx_n/solution.test.ts b/src/test/ts/g0001_0100/s0050_powx_n/solution.test.ts new file mode 100644 index 0000000..1279265 --- /dev/null +++ b/src/test/ts/g0001_0100/s0050_powx_n/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { myPow } from 'src/main/ts/g0001_0100/s0050_powx_n/solution' +import { expect, test } from 'vitest' + +test('myPow', () => { + expect(myPow(2.00000, 10)).toEqual(1024.00000) +}) + +test('myPow2', () => { + expect(myPow(2.10000, 3)).toEqual(9.261000000000001) +}) + +test('myPow3', () => { + expect(myPow(2.00000, -2)).toEqual(0.25000) +}) diff --git a/src/test/ts/g0001_0100/s0052_n_queens_ii/solution.test.ts b/src/test/ts/g0001_0100/s0052_n_queens_ii/solution.test.ts new file mode 100644 index 0000000..456c671 --- /dev/null +++ b/src/test/ts/g0001_0100/s0052_n_queens_ii/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { totalNQueens } from 'src/main/ts/g0001_0100/s0052_n_queens_ii/solution' +import { expect, test } from 'vitest' + +test('totalNQueens', () => { + expect(totalNQueens(4)).toEqual(2) +}) + +test('totalNQueens2', () => { + expect(totalNQueens(1)).toEqual(1) +}) diff --git a/src/test/ts/g0001_0100/s0054_spiral_matrix/solution.test.ts b/src/test/ts/g0001_0100/s0054_spiral_matrix/solution.test.ts new file mode 100644 index 0000000..0a5f01e --- /dev/null +++ b/src/test/ts/g0001_0100/s0054_spiral_matrix/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { spiralOrder } from 'src/main/ts/g0001_0100/s0054_spiral_matrix/solution' +import { expect, test } from 'vitest' + +test('spiralOrder', () => { + expect(spiralOrder([[1,2,3],[4,5,6],[7,8,9]])).toEqual([1,2,3,6,9,8,7,4,5]) +}) + +test('spiralOrder2', () => { + expect(spiralOrder([[1,2,3,4],[5,6,7,8],[9,10,11,12]])).toEqual([1,2,3,4,8,12,11,10,9,5,6,7]) +}) From 4ddc75e27bd93fb5d100a58ef8d03aa2e096435d Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Wed, 2 Apr 2025 07:50:25 +0300 Subject: [PATCH 20/49] Improved tasks 30-54 --- .../solution.ts | 44 +++++++++---------- .../g0001_0100/s0036_valid_sudoku/solution.ts | 24 +++++----- .../ts/g0001_0100/s0050_powx_n/solution.ts | 16 +++---- .../g0001_0100/s0052_n_queens_ii/solution.ts | 14 +++--- .../s0054_spiral_matrix/solution.ts | 27 ++++++------ .../solution.ts | 6 +-- .../solution.ts | 2 +- .../solution.test.ts | 4 +- .../solution.test.ts | 4 +- .../s0027_remove_element/solution.test.ts | 4 +- .../solution.test.ts | 6 +-- .../s0036_valid_sudoku/solution.test.ts | 44 +++++++++++-------- .../g0001_0100/s0050_powx_n/solution.test.ts | 6 +-- .../s0054_spiral_matrix/solution.test.ts | 16 ++++++- 14 files changed, 119 insertions(+), 98 deletions(-) diff --git a/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts b/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts index d62f490..2470100 100644 --- a/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts +++ b/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts @@ -2,47 +2,47 @@ // #2025_04_01_Time_13_ms_(97.44%)_Space_63.70_MB_(46.03%) function findSubstring(s: string, words: string[]): number[] { - let ans: number[] = []; - let n1 = words[0].length; - let n2 = s.length; - let map1 = new Map(); + let ans: number[] = [] + let n1 = words[0].length + let n2 = s.length + let map1 = new Map() for (let ch of words) { - map1.set(ch, (map1.get(ch) ?? 0) + 1); + map1.set(ch, (map1.get(ch) ?? 0) + 1) } for (let i = 0; i < n1; i++) { - let left = i; - let j = i; - let c = 0; - let map2 = new Map(); + let left = i + let j = i + let c = 0 + let map2 = new Map() while (j + n1 <= n2) { - let word1 = s.substring(j, j + n1); - j += n1; + let word1 = s.substring(j, j + n1) + j += n1 if (map1.has(word1)) { - map2.set(word1, (map2.get(word1) ?? 0) + 1); - c++; + map2.set(word1, (map2.get(word1) ?? 0) + 1) + c++ while ((map2.get(word1) ?? 0) > (map1.get(word1) ?? 0)) { - let word2 = s.substring(left, left + n1); - map2.set(word2, (map2.get(word2) ?? 0) - 1); - left += n1; - c--; + let word2 = s.substring(left, left + n1) + map2.set(word2, (map2.get(word2) ?? 0) - 1) + left += n1 + c-- } if (c === words.length) { - ans.push(left); + ans.push(left) } } else { - map2.clear(); - c = 0; - left = j; + map2.clear() + c = 0 + left = j } } } - return ans; + return ans } export { findSubstring } diff --git a/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts b/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts index 42a4760..315eee3 100644 --- a/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts +++ b/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts @@ -2,28 +2,28 @@ // #Top_Interview_150_Matrix #2025_04_01_Time_1_ms_(99.60%)_Space_58.94_MB_(52.85%) function isValidSudoku(board: string[][]): boolean { - let rowSet: number[] = new Array(9).fill(0); - let colSet: number[] = new Array(9).fill(0); - let boxSet: number[] = new Array(9).fill(0); + let rowSet: number[] = new Array(9).fill(0) + let colSet: number[] = new Array(9).fill(0) + let boxSet: number[] = new Array(9).fill(0) for (let i = 0; i < 9; i++) { for (let j = 0; j < 9; j++) { if (board[i][j] === '.') { - continue; + continue } - let val = board[i][j].charCodeAt(0) - '0'.charCodeAt(0); - let boxIndex = Math.floor(i / 3) * 3 + Math.floor(j / 3); + let val = board[i][j].charCodeAt(0) - '0'.charCodeAt(0) + let boxIndex = Math.floor(i / 3) * 3 + Math.floor(j / 3) - if ((rowSet[i] & (1 << val)) || (colSet[j] & (1 << val)) || (boxSet[boxIndex] & (1 << val))) { - return false; + if (rowSet[i] & (1 << val) || colSet[j] & (1 << val) || boxSet[boxIndex] & (1 << val)) { + return false } - rowSet[i] |= 1 << val; - colSet[j] |= 1 << val; - boxSet[boxIndex] |= 1 << val; + rowSet[i] |= 1 << val + colSet[j] |= 1 << val + boxSet[boxIndex] |= 1 << val } } - return true; + return true } export { isValidSudoku } diff --git a/src/main/ts/g0001_0100/s0050_powx_n/solution.ts b/src/main/ts/g0001_0100/s0050_powx_n/solution.ts index 66ab82b..ec47d5f 100644 --- a/src/main/ts/g0001_0100/s0050_powx_n/solution.ts +++ b/src/main/ts/g0001_0100/s0050_powx_n/solution.ts @@ -2,21 +2,21 @@ // #2025_04_01_Time_0_ms_(100.00%)_Space_57.31_MB_(7.22%) function myPow(x: number, n: number): number { - let nn = BigInt(n); - let res = 1.0; + let nn = BigInt(n) + let res = 1.0 if (n < 0) { - nn = -nn; + nn = -nn } while (nn > 0) { if (nn % 2n === 1n) { - nn--; - res *= x; + nn-- + res *= x } else { - x *= x; - nn /= 2n; + x *= x + nn /= 2n } } - return n < 0 ? 1.0 / res : res; + return n < 0 ? 1.0 / res : res } export { myPow } diff --git a/src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts b/src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts index 0bf35b2..e0ff9b0 100644 --- a/src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts +++ b/src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts @@ -4,19 +4,19 @@ function totalNQueens(n: number): number { function solve(r: number, cols: boolean[], diag: boolean[], antiDiag: boolean[]): number { if (r === n) { - return 1; + return 1 } - let count = 0; + let count = 0 for (let c = 0; c < n; c++) { if (!cols[c] && !diag[r + c] && !antiDiag[r - c + n - 1]) { - cols[c] = diag[r + c] = antiDiag[r - c + n - 1] = true; - count += solve(r + 1, cols, diag, antiDiag); - cols[c] = diag[r + c] = antiDiag[r - c + n - 1] = false; + cols[c] = diag[r + c] = antiDiag[r - c + n - 1] = true + count += solve(r + 1, cols, diag, antiDiag) + cols[c] = diag[r + c] = antiDiag[r - c + n - 1] = false } } - return count; + return count } - return solve(0, new Array(n).fill(false), new Array(2 * n - 1).fill(false), new Array(2 * n - 1).fill(false)); + return solve(0, new Array(n).fill(false), new Array(2 * n - 1).fill(false), new Array(2 * n - 1).fill(false)) } export { totalNQueens } diff --git a/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts b/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts index a1b56f0..3cfb163 100644 --- a/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts +++ b/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts @@ -3,34 +3,35 @@ // #Top_Interview_150_Matrix #2025_04_01_Time_0_ms_(100.00%)_Space_55.71_MB_(30.13%) function spiralOrder(matrix: number[][]): number[] { - const result: number[] = []; - let r = 0, c = 0; - let bigR = matrix.length - 1; - let bigC = matrix[0].length - 1; + const result: number[] = [] + let r = 0, + c = 0 + let bigR = matrix.length - 1 + let bigC = matrix[0].length - 1 while (r <= bigR && c <= bigC) { for (let i = c; i <= bigC; i++) { - result.push(matrix[r][i]); + result.push(matrix[r][i]) } - r++; + r++ for (let i = r; i <= bigR; i++) { - result.push(matrix[i][bigC]); + result.push(matrix[i][bigC]) } - bigC--; + bigC-- for (let i = bigC; i >= c && r <= bigR; i--) { - result.push(matrix[bigR][i]); + result.push(matrix[bigR][i]) } - bigR--; + bigR-- for (let i = bigR; i >= r && c <= bigC; i--) { - result.push(matrix[i][c]); + result.push(matrix[i][c]) } - c++; + c++ } - return result; + return result } export { spiralOrder } diff --git a/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts b/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts index 4519a5d..6a78603 100644 --- a/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts +++ b/src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts @@ -7,9 +7,9 @@ function longestConsecutive(nums: number[]): number { let maxLen = 0 for (let num of sset) { // check its start of the sequence - if (!sset.has(num-1)) { - let len = 0; - while (sset.has(num+len)) { + if (!sset.has(num - 1)) { + let len = 0 + while (sset.has(num + len)) { len += 1 } maxLen = Math.max(maxLen, len) diff --git a/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts b/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts index 87fa919..ab5f7da 100644 --- a/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts +++ b/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts @@ -7,7 +7,7 @@ function findKthLargest(nums: number[], k: number): number { const countingLen = 2e4 + 1 const counting = new Int32Array(countingLen) for (const num of nums) { - counting[num + 1e4]++; + counting[num + 1e4]++ } for (let i = countingLen - 1; i >= 0; i--) { k -= counting[i] diff --git a/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts b/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts index 6e12553..62b1934 100644 --- a/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts +++ b/src/test/ts/g0001_0100/s0014_longest_common_prefix/solution.test.ts @@ -3,11 +3,11 @@ import { longestCommonPrefix } from 'src/main/ts/g0001_0100/s0014_longest_common import { expect, test } from 'vitest' test('longestCommonPrefix', () => { - expect(longestCommonPrefix(['flower','flow','flight'])).toEqual('fl') + expect(longestCommonPrefix(['flower', 'flow', 'flight'])).toEqual('fl') }) test('longestCommonPrefix2', () => { - expect(longestCommonPrefix(['dog','racecar','car'])).toEqual('') + expect(longestCommonPrefix(['dog', 'racecar', 'car'])).toEqual('') }) test('longestCommonPrefix3', () => { diff --git a/src/test/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.test.ts b/src/test/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.test.ts index 24c5a76..b8e0f40 100644 --- a/src/test/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.test.ts +++ b/src/test/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.test.ts @@ -3,9 +3,9 @@ import { removeDuplicates } from 'src/main/ts/g0001_0100/s0026_remove_duplicates import { expect, test } from 'vitest' test('removeDuplicates', () => { - expect(removeDuplicates([1,1,2])).toEqual(2) + expect(removeDuplicates([1, 1, 2])).toEqual(2) }) test('removeDuplicates2', () => { - expect(removeDuplicates([0,0,1,1,1,2,2,3,3,4])).toEqual(5) + expect(removeDuplicates([0, 0, 1, 1, 1, 2, 2, 3, 3, 4])).toEqual(5) }) diff --git a/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts b/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts index fdf08c6..08f06fd 100644 --- a/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts +++ b/src/test/ts/g0001_0100/s0027_remove_element/solution.test.ts @@ -3,11 +3,11 @@ import { removeElement } from 'src/main/ts/g0001_0100/s0027_remove_element/solut import { expect, test } from 'vitest' test('removeElement', () => { - expect(removeElement([3,2,2,3], 3)).toEqual(2) + expect(removeElement([3, 2, 2, 3], 3)).toEqual(2) }) test('removeElement2', () => { - expect(removeElement([0,1,2,2,3,0,4,2], 2)).toEqual(5) + expect(removeElement([0, 1, 2, 2, 3, 0, 4, 2], 2)).toEqual(5) }) test('removeElement3', () => { diff --git a/src/test/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.test.ts b/src/test/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.test.ts index 4c4fe7d..03206ff 100644 --- a/src/test/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.test.ts +++ b/src/test/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.test.ts @@ -3,13 +3,13 @@ import { findSubstring } from 'src/main/ts/g0001_0100/s0030_substring_with_conca import { expect, test } from 'vitest' test('findSubstring', () => { - expect(findSubstring('barfoothefoobarman', ['foo','bar'])).toEqual([0,9]) + expect(findSubstring('barfoothefoobarman', ['foo', 'bar'])).toEqual([0, 9]) }) test('findSubstring2', () => { - expect(findSubstring('wordgoodgoodgoodbestword', ['word','good','best','word'])).toEqual([]) + expect(findSubstring('wordgoodgoodgoodbestword', ['word', 'good', 'best', 'word'])).toEqual([]) }) test('findSubstring3', () => { - expect(findSubstring('barfoofoobarthefoobarman', ['bar','foo','the'])).toEqual([6,9,12]) + expect(findSubstring('barfoofoobarthefoobarman', ['bar', 'foo', 'the'])).toEqual([6, 9, 12]) }) diff --git a/src/test/ts/g0001_0100/s0036_valid_sudoku/solution.test.ts b/src/test/ts/g0001_0100/s0036_valid_sudoku/solution.test.ts index db4ff72..36659a9 100644 --- a/src/test/ts/g0001_0100/s0036_valid_sudoku/solution.test.ts +++ b/src/test/ts/g0001_0100/s0036_valid_sudoku/solution.test.ts @@ -3,25 +3,33 @@ import { isValidSudoku } from 'src/main/ts/g0001_0100/s0036_valid_sudoku/solutio import { expect, test } from 'vitest' test('isValidSudoku', () => { - expect(isValidSudoku([['5','3','.','.','7','.','.','.','.'] - ,['6','.','.','1','9','5','.','.','.'] - ,['.','9','8','.','.','.','.','6','.'] - ,['8','.','.','.','6','.','.','.','3'] - ,['4','.','.','8','.','3','.','.','1'] - ,['7','.','.','.','2','.','.','.','6'] - ,['.','6','.','.','.','.','2','8','.'] - ,['.','.','.','4','1','9','.','.','5'] - ,['.','.','.','.','8','.','.','7','9']])).toEqual(true) + expect( + isValidSudoku([ + ['5', '3', '.', '.', '7', '.', '.', '.', '.'], + ['6', '.', '.', '1', '9', '5', '.', '.', '.'], + ['.', '9', '8', '.', '.', '.', '.', '6', '.'], + ['8', '.', '.', '.', '6', '.', '.', '.', '3'], + ['4', '.', '.', '8', '.', '3', '.', '.', '1'], + ['7', '.', '.', '.', '2', '.', '.', '.', '6'], + ['.', '6', '.', '.', '.', '.', '2', '8', '.'], + ['.', '.', '.', '4', '1', '9', '.', '.', '5'], + ['.', '.', '.', '.', '8', '.', '.', '7', '9'], + ]), + ).toEqual(true) }) test('isValidSudoku2', () => { - expect(isValidSudoku([['8','3','.','.','7','.','.','.','.'] - ,['6','.','.','1','9','5','.','.','.'] - ,['.','9','8','.','.','.','.','6','.'] - ,['8','.','.','.','6','.','.','.','3'] - ,['4','.','.','8','.','3','.','.','1'] - ,['7','.','.','.','2','.','.','.','6'] - ,['.','6','.','.','.','.','2','8','.'] - ,['.','.','.','4','1','9','.','.','5'] - ,['.','.','.','.','8','.','.','7','9']])).toEqual(false) + expect( + isValidSudoku([ + ['8', '3', '.', '.', '7', '.', '.', '.', '.'], + ['6', '.', '.', '1', '9', '5', '.', '.', '.'], + ['.', '9', '8', '.', '.', '.', '.', '6', '.'], + ['8', '.', '.', '.', '6', '.', '.', '.', '3'], + ['4', '.', '.', '8', '.', '3', '.', '.', '1'], + ['7', '.', '.', '.', '2', '.', '.', '.', '6'], + ['.', '6', '.', '.', '.', '.', '2', '8', '.'], + ['.', '.', '.', '4', '1', '9', '.', '.', '5'], + ['.', '.', '.', '.', '8', '.', '.', '7', '9'], + ]), + ).toEqual(false) }) diff --git a/src/test/ts/g0001_0100/s0050_powx_n/solution.test.ts b/src/test/ts/g0001_0100/s0050_powx_n/solution.test.ts index 1279265..40375e2 100644 --- a/src/test/ts/g0001_0100/s0050_powx_n/solution.test.ts +++ b/src/test/ts/g0001_0100/s0050_powx_n/solution.test.ts @@ -3,13 +3,13 @@ import { myPow } from 'src/main/ts/g0001_0100/s0050_powx_n/solution' import { expect, test } from 'vitest' test('myPow', () => { - expect(myPow(2.00000, 10)).toEqual(1024.00000) + expect(myPow(2.0, 10)).toEqual(1024.0) }) test('myPow2', () => { - expect(myPow(2.10000, 3)).toEqual(9.261000000000001) + expect(myPow(2.1, 3)).toEqual(9.261000000000001) }) test('myPow3', () => { - expect(myPow(2.00000, -2)).toEqual(0.25000) + expect(myPow(2.0, -2)).toEqual(0.25) }) diff --git a/src/test/ts/g0001_0100/s0054_spiral_matrix/solution.test.ts b/src/test/ts/g0001_0100/s0054_spiral_matrix/solution.test.ts index 0a5f01e..bb2901e 100644 --- a/src/test/ts/g0001_0100/s0054_spiral_matrix/solution.test.ts +++ b/src/test/ts/g0001_0100/s0054_spiral_matrix/solution.test.ts @@ -3,9 +3,21 @@ import { spiralOrder } from 'src/main/ts/g0001_0100/s0054_spiral_matrix/solution import { expect, test } from 'vitest' test('spiralOrder', () => { - expect(spiralOrder([[1,2,3],[4,5,6],[7,8,9]])).toEqual([1,2,3,6,9,8,7,4,5]) + expect( + spiralOrder([ + [1, 2, 3], + [4, 5, 6], + [7, 8, 9], + ]), + ).toEqual([1, 2, 3, 6, 9, 8, 7, 4, 5]) }) test('spiralOrder2', () => { - expect(spiralOrder([[1,2,3,4],[5,6,7,8],[9,10,11,12]])).toEqual([1,2,3,4,8,12,11,10,9,5,6,7]) + expect( + spiralOrder([ + [1, 2, 3, 4], + [5, 6, 7, 8], + [9, 10, 11, 12], + ]), + ).toEqual([1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7]) }) From 9a33707011cda5d0b19ca1d153b874f971305d88 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Wed, 2 Apr 2025 22:36:00 +0700 Subject: [PATCH 21/49] Added tasks 57-66 --- README.md | 18 +++++++ .../s0057_insert_interval/readme.md | 50 +++++++++++++++++++ .../s0057_insert_interval/solution.ts | 28 +++++++++++ .../s0058_length_of_last_word/readme.md | 37 ++++++++++++++ .../s0058_length_of_last_word/solution.ts | 17 +++++++ .../ts/g0001_0100/s0061_rotate_list/readme.md | 27 ++++++++++ .../g0001_0100/s0061_rotate_list/solution.ts | 39 +++++++++++++++ .../s0063_unique_paths_ii/readme.md | 36 +++++++++++++ .../s0063_unique_paths_ii/solution.ts | 37 ++++++++++++++ .../ts/g0001_0100/s0066_plus_one/readme.md | 45 +++++++++++++++++ .../ts/g0001_0100/s0066_plus_one/solution.ts | 23 +++++++++ .../s0057_insert_interval/solution.test.ts | 11 ++++ .../solution.test.ts | 15 ++++++ .../s0061_rotate_list/solution.test.ts | 12 +++++ .../s0063_unique_paths_ii/solution.test.ts | 11 ++++ .../s0066_plus_one/solution.test.ts | 15 ++++++ 16 files changed, 421 insertions(+) create mode 100644 src/main/ts/g0001_0100/s0057_insert_interval/readme.md create mode 100644 src/main/ts/g0001_0100/s0057_insert_interval/solution.ts create mode 100644 src/main/ts/g0001_0100/s0058_length_of_last_word/readme.md create mode 100644 src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts create mode 100644 src/main/ts/g0001_0100/s0061_rotate_list/readme.md create mode 100644 src/main/ts/g0001_0100/s0061_rotate_list/solution.ts create mode 100644 src/main/ts/g0001_0100/s0063_unique_paths_ii/readme.md create mode 100644 src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts create mode 100644 src/main/ts/g0001_0100/s0066_plus_one/readme.md create mode 100644 src/main/ts/g0001_0100/s0066_plus_one/solution.ts create mode 100644 src/test/ts/g0001_0100/s0057_insert_interval/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0058_length_of_last_word/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0061_rotate_list/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0063_unique_paths_ii/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0066_plus_one/solution.test.ts diff --git a/README.md b/README.md index f48ae7c..cc3be26 100644 --- a/README.md +++ b/README.md @@ -287,6 +287,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 0063 |[Unique Paths II](src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 #### Day 16 @@ -406,6 +407,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 #### Day 4 @@ -422,6 +424,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 18 | 80.57 +| 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String | 0 | 100.00 #### Day 7 @@ -478,6 +481,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0061 |[Rotate List](src/main/ts/g0001_0100/s0061_rotate_list/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 #### Day 17 @@ -820,6 +824,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0057 |[Insert Interval](src/main/ts/g0001_0100/s0057_insert_interval/solution.ts)| Medium | Array | 0 | 100.00 | 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 #### Day 18 Stack @@ -875,9 +880,11 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 | 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 +| 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String | 0 | 100.00 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 | 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 1 | 99.11 | 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 26 | 99.07 @@ -917,6 +924,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0061 |[Rotate List](src/main/ts/g0001_0100/s0061_rotate_list/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 | 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 51 | 76.99 | 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 47 | 89.37 @@ -1006,6 +1014,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0013 |[Roman to Integer](src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Math | 3 | 94.58 | 0012 |[Integer to Roman](src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts)| Medium | String, Hash_Table, Math | 3 | 93.02 +| 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String | 0 | 100.00 | 0014 |[Longest Common Prefix](src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String | 0 | 100.00 | 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 2 | 99.08 | 0028 |[Implement strStr()](src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 @@ -1047,6 +1056,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 +| 0057 |[Insert Interval](src/main/ts/g0001_0100/s0057_insert_interval/solution.ts)| Medium | Array | 0 | 100.00 #### Top Interview 150 Stack @@ -1065,6 +1075,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 49 | 72.42 | 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 | 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 +| 0061 |[Rotate List](src/main/ts/g0001_0100/s0061_rotate_list/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 | 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 97 | 81.52 #### Top Interview 150 Binary Tree General @@ -1163,6 +1174,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 +| 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 | 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 #### Top Interview 150 1D DP @@ -1180,6 +1192,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 +| 0063 |[Unique Paths II](src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 @@ -1683,8 +1696,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 4 | 50.63 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_2, Level_1_Day_10_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math, Programming_Skills_II_Day_3, Udemy_Arrays, Top_Interview_150_Math | 0 | 100.00 | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 +| 0063 |[Unique Paths II](src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_15, Top_Interview_150_Multidimensional_DP | 0 | 100.00 | 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_15, Level_1_Day_11_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 0061 |[Rotate List](src/main/ts/g0001_0100/s0061_rotate_list/solution.ts)| Medium | Two_Pointers, Linked_List, Programming_Skills_II_Day_16, Udemy_Linked_List, Top_Interview_150_Linked_List | 0 | 100.00 +| 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String, Programming_Skills_II_Day_6, Udemy_Arrays, Top_Interview_150_Array/String | 0 | 100.00 +| 0057 |[Insert Interval](src/main/ts/g0001_0100/s0057_insert_interval/solution.ts)| Medium | Array, Level_2_Day_17_Interval, Top_Interview_150_Intervals | 0 | 100.00 | 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Data_Structure_II_Day_2_Array, Level_2_Day_17_Interval, Udemy_2D_Arrays/Matrix, Top_Interview_150_Intervals, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_4, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0054 |[Spiral Matrix](src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation, Programming_Skills_II_Day_8, Level_2_Day_1_Implementation/Simulation, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix | 0 | 100.00 diff --git a/src/main/ts/g0001_0100/s0057_insert_interval/readme.md b/src/main/ts/g0001_0100/s0057_insert_interval/readme.md new file mode 100644 index 0000000..2a9c2e3 --- /dev/null +++ b/src/main/ts/g0001_0100/s0057_insert_interval/readme.md @@ -0,0 +1,50 @@ +57\. Insert Interval + +Medium + +You are given an array of non-overlapping intervals `intervals` where intervals[i] = [starti, endi] represent the start and the end of the ith interval and `intervals` is sorted in ascending order by starti. You are also given an interval `newInterval = [start, end]` that represents the start and end of another interval. + +Insert `newInterval` into `intervals` such that `intervals` is still sorted in ascending order by starti and `intervals` still does not have any overlapping intervals (merge overlapping intervals if necessary). + +Return `intervals` _after the insertion_. + +**Example 1:** + +**Input:** intervals = [[1,3],[6,9]], newInterval = [2,5] + +**Output:** [[1,5],[6,9]] + +**Example 2:** + +**Input:** intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8] + +**Output:** [[1,2],[3,10],[12,16]] + +**Explanation:** Because the new interval `[4,8]` overlaps with `[3,5],[6,7],[8,10]`. + +**Example 3:** + +**Input:** intervals = [], newInterval = [5,7] + +**Output:** [[5,7]] + +**Example 4:** + +**Input:** intervals = [[1,5]], newInterval = [2,3] + +**Output:** [[1,5]] + +**Example 5:** + +**Input:** intervals = [[1,5]], newInterval = [2,7] + +**Output:** [[1,7]] + +**Constraints:** + +* 0 <= intervals.length <= 104 +* `intervals[i].length == 2` +* 0 <= starti <= endi <= 105 +* `intervals` is sorted by starti in **ascending** order. +* `newInterval.length == 2` +* 0 <= start <= end <= 105 diff --git a/src/main/ts/g0001_0100/s0057_insert_interval/solution.ts b/src/main/ts/g0001_0100/s0057_insert_interval/solution.ts new file mode 100644 index 0000000..1af2bd4 --- /dev/null +++ b/src/main/ts/g0001_0100/s0057_insert_interval/solution.ts @@ -0,0 +1,28 @@ +// #Medium #Array #Level_2_Day_17_Interval #Top_Interview_150_Intervals +// #2025_04_02_Time_0_ms_(100.00%)_Space_58.54_MB_(66.77%) + +function insert(intervals: number[][], newInterval: number[]): number[][] { + const n = intervals.length + let l = 0 + let r = n - 1 + while (l < n && newInterval[0] > intervals[l][1]) { + l++ + } + while (r >= 0 && newInterval[1] < intervals[r][0]) { + r-- + } + const res: number[][] = new Array(l + n - r).fill(0).map(() => new Array(2)) + for (let i = 0; i < l; i++) { + res[i] = [...intervals[i]] + } + res[l] = [ + Math.min(newInterval[0], l === n ? newInterval[0] : intervals[l][0]), + Math.max(newInterval[1], r === -1 ? newInterval[1] : intervals[r][1]) + ] + for (let i = l + 1, j = r + 1; j < n; i++, j++) { + res[i] = intervals[j] + } + return res +} + +export { insert } diff --git a/src/main/ts/g0001_0100/s0058_length_of_last_word/readme.md b/src/main/ts/g0001_0100/s0058_length_of_last_word/readme.md new file mode 100644 index 0000000..8e8e6c7 --- /dev/null +++ b/src/main/ts/g0001_0100/s0058_length_of_last_word/readme.md @@ -0,0 +1,37 @@ +58\. Length of Last Word + +Easy + +Given a string `s` consisting of some words separated by some number of spaces, return _the length of the **last** word in the string._ + +A **word** is a maximal substring consisting of non-space characters only. + +**Example 1:** + +**Input:** s = "Hello World" + +**Output:** 5 + +**Explanation:** The last word is "World" with length 5. + +**Example 2:** + +**Input:** s = " fly me to the moon " + +**Output:** 4 + +**Explanation:** The last word is "moon" with length 4. + +**Example 3:** + +**Input:** s = "luffy is still joyboy" + +**Output:** 6 + +**Explanation:** The last word is "joyboy" with length 6. + +**Constraints:** + +* 1 <= s.length <= 104 +* `s` consists of only English letters and spaces `' '`. +* There will be at least one word in `s`. diff --git a/src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts b/src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts new file mode 100644 index 0000000..b3a2e81 --- /dev/null +++ b/src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts @@ -0,0 +1,17 @@ +// #Easy #String #Programming_Skills_II_Day_6 #Udemy_Arrays #Top_Interview_150_Array/String +// #2025_04_02_Time_0_ms_(100.00%)_Space_56.32_MB_(7.86%) + +function lengthOfLastWord(s: string): number { + let len = 0 + for (let i = s.length - 1; i >= 0; i--) { + const ch = s[i] + if (ch === ' ' && len > 0) { + break + } else if (ch !== ' ') { + len++ + } + } + return len +} + +export { lengthOfLastWord } diff --git a/src/main/ts/g0001_0100/s0061_rotate_list/readme.md b/src/main/ts/g0001_0100/s0061_rotate_list/readme.md new file mode 100644 index 0000000..aeb6530 --- /dev/null +++ b/src/main/ts/g0001_0100/s0061_rotate_list/readme.md @@ -0,0 +1,27 @@ +61\. Rotate List + +Medium + +Given the `head` of a linked list, rotate the list to the right by `k` places. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/11/13/rotate1.jpg) + +**Input:** head = [1,2,3,4,5], k = 2 + +**Output:** [4,5,1,2,3] + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2020/11/13/roate2.jpg) + +**Input:** head = [0,1,2], k = 4 + +**Output:** [2,0,1] + +**Constraints:** + +* The number of nodes in the list is in the range `[0, 500]`. +* `-100 <= Node.val <= 100` +* 0 <= k <= 2 * 109 diff --git a/src/main/ts/g0001_0100/s0061_rotate_list/solution.ts b/src/main/ts/g0001_0100/s0061_rotate_list/solution.ts new file mode 100644 index 0000000..70b5f08 --- /dev/null +++ b/src/main/ts/g0001_0100/s0061_rotate_list/solution.ts @@ -0,0 +1,39 @@ +// #Medium #Two_Pointers #Linked_List #Programming_Skills_II_Day_16 #Udemy_Linked_List +// #Top_Interview_150_Linked_List #2025_04_02_Time_0_ms_(100.00%)_Space_58.23_MB_(55.89%) + +/** + * Definition for singly-linked list. + * class ListNode { + * val: number + * next: ListNode | null + * constructor(val?: number, next?: ListNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.next = (next===undefined ? null : next) + * } + * } + */ +function rotateRight(head: ListNode | null, k: number): ListNode | null { + if (!head || k === 0) { + return head + } + let tail: ListNode | null = head + let count = 1 + while (tail.next) { + count++ + tail = tail.next + } + let times = k % count + if (times === 0) { + return head + } + let temp: ListNode | null = head + for (let i = 1; i < count - times; i++) { + temp = temp!.next + } + let newHead = temp!.next + temp!.next = null + tail!.next = head + return newHead +} + +export { rotateRight } diff --git a/src/main/ts/g0001_0100/s0063_unique_paths_ii/readme.md b/src/main/ts/g0001_0100/s0063_unique_paths_ii/readme.md new file mode 100644 index 0000000..9009889 --- /dev/null +++ b/src/main/ts/g0001_0100/s0063_unique_paths_ii/readme.md @@ -0,0 +1,36 @@ +63\. Unique Paths II + +Medium + +A robot is located at the top-left corner of a `m x n` grid (marked 'Start' in the diagram below). + +The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). + +Now consider if some obstacles are added to the grids. How many unique paths would there be? + +An obstacle and space is marked as `1` and `0` respectively in the grid. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/11/04/robot1.jpg) + +**Input:** obstacleGrid = [[0,0,0],[0,1,0],[0,0,0]] + +**Output:** 2 + +**Explanation:** There is one obstacle in the middle of the 3x3 grid above. There are two ways to reach the bottom-right corner: 1. Right -> Right -> Down -> Down 2. Down -> Down -> Right -> Right + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2020/11/04/robot2.jpg) + +**Input:** obstacleGrid = [[0,1],[0,0]] + +**Output:** 1 + +**Constraints:** + +* `m == obstacleGrid.length` +* `n == obstacleGrid[i].length` +* `1 <= m, n <= 100` +* `obstacleGrid[i][j]` is `0` or `1`. diff --git a/src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts b/src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts new file mode 100644 index 0000000..14dd49c --- /dev/null +++ b/src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts @@ -0,0 +1,37 @@ +// #Medium #Array #Dynamic_Programming #Matrix #Dynamic_Programming_I_Day_15 +// #Top_Interview_150_Multidimensional_DP #2025_04_02_Time_0_ms_(100.00%)_Space_55.75_MB_(56.77%) + +function uniquePathsWithObstacles(obstacleGrid: number[][]): number { + if (obstacleGrid[0][0] === 1) { + return 0 + } + obstacleGrid[0][0] = 1 + const m = obstacleGrid.length + const n = obstacleGrid[0].length + for (let i = 1; i < m; i++) { + if (obstacleGrid[i][0] === 1) { + obstacleGrid[i][0] = 0 + } else { + obstacleGrid[i][0] = obstacleGrid[i - 1][0] + } + } + for (let j = 1; j < n; j++) { + if (obstacleGrid[0][j] === 1) { + obstacleGrid[0][j] = 0 + } else { + obstacleGrid[0][j] = obstacleGrid[0][j - 1] + } + } + for (let i = 1; i < m; i++) { + for (let j = 1; j < n; j++) { + if (obstacleGrid[i][j] === 1) { + obstacleGrid[i][j] = 0 + } else { + obstacleGrid[i][j] = obstacleGrid[i - 1][j] + obstacleGrid[i][j - 1] + } + } + } + return obstacleGrid[m - 1][n - 1] +} + +export { uniquePathsWithObstacles } diff --git a/src/main/ts/g0001_0100/s0066_plus_one/readme.md b/src/main/ts/g0001_0100/s0066_plus_one/readme.md new file mode 100644 index 0000000..83b683f --- /dev/null +++ b/src/main/ts/g0001_0100/s0066_plus_one/readme.md @@ -0,0 +1,45 @@ +66\. Plus One + +Easy + +You are given a **large integer** represented as an integer array `digits`, where each `digits[i]` is the `ith` digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading `0`'s. + +Increment the large integer by one and return _the resulting array of digits_. + +**Example 1:** + +**Input:** digits = [1,2,3] + +**Output:** [1,2,4] + +**Explanation:** The array represents the integer 123. Incrementing by one gives 123 + 1 = 124. Thus, the result should be [1,2,4]. + +**Example 2:** + +**Input:** digits = [4,3,2,1] + +**Output:** [4,3,2,2] + +**Explanation:** The array represents the integer 4321. Incrementing by one gives 4321 + 1 = 4322. Thus, the result should be [4,3,2,2]. + +**Example 3:** + +**Input:** digits = [0] + +**Output:** [1] + +**Explanation:** The array represents the integer 0. Incrementing by one gives 0 + 1 = 1. Thus, the result should be [1]. + +**Example 4:** + +**Input:** digits = [9] + +**Output:** [1,0] + +**Explanation:** The array represents the integer 9. Incrementing by one gives 9 + 1 = 10. Thus, the result should be [1,0]. + +**Constraints:** + +* `1 <= digits.length <= 100` +* `0 <= digits[i] <= 9` +* `digits` does not contain any leading `0`'s. diff --git a/src/main/ts/g0001_0100/s0066_plus_one/solution.ts b/src/main/ts/g0001_0100/s0066_plus_one/solution.ts new file mode 100644 index 0000000..45b8485 --- /dev/null +++ b/src/main/ts/g0001_0100/s0066_plus_one/solution.ts @@ -0,0 +1,23 @@ +// #Easy #Top_Interview_Questions #Array #Math #Programming_Skills_II_Day_3 #Udemy_Arrays +// #Top_Interview_150_Math #2025_04_02_Time_0_ms_(100.00%)_Space_55.60_MB_(44.68%) + +function plusOne(digits: number[]): number[] { + let num = 1 + let carry = 0 + let sum + for (let i = digits.length - 1; i >= 0; i--) { + if (i === digits.length - 1) { + sum = digits[i] + carry + num + } else { + sum = digits[i] + carry + } + carry = Math.floor(sum / 10) + digits[i] = sum % 10 + } + if (carry !== 0) { + return [carry, ...digits] + } + return digits +} + +export { plusOne } diff --git a/src/test/ts/g0001_0100/s0057_insert_interval/solution.test.ts b/src/test/ts/g0001_0100/s0057_insert_interval/solution.test.ts new file mode 100644 index 0000000..614db04 --- /dev/null +++ b/src/test/ts/g0001_0100/s0057_insert_interval/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { insert } from 'src/main/ts/g0001_0100/s0057_insert_interval/solution' +import { expect, test } from 'vitest' + +test('insert', () => { + expect(insert([[1,3],[6,9]], [2,5])).toEqual([[1,5],[6,9]]) +}) + +test('insert2', () => { + expect(insert( [[1,2],[3,5],[6,7],[8,10],[12,16]], [4,8])).toEqual([[1,2],[3,10],[12,16]]) +}) diff --git a/src/test/ts/g0001_0100/s0058_length_of_last_word/solution.test.ts b/src/test/ts/g0001_0100/s0058_length_of_last_word/solution.test.ts new file mode 100644 index 0000000..d3bb8fd --- /dev/null +++ b/src/test/ts/g0001_0100/s0058_length_of_last_word/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { lengthOfLastWord } from 'src/main/ts/g0001_0100/s0058_length_of_last_word/solution' +import { expect, test } from 'vitest' + +test('lengthOfLastWord', () => { + expect(lengthOfLastWord('Hello World')).toEqual(5) +}) + +test('lengthOfLastWord2', () => { + expect(lengthOfLastWord(' fly me to the moon ')).toEqual(4) +}) + +test('lengthOfLastWord3', () => { + expect(lengthOfLastWord('luffy is still joyboy')).toEqual(6) +}) diff --git a/src/test/ts/g0001_0100/s0061_rotate_list/solution.test.ts b/src/test/ts/g0001_0100/s0061_rotate_list/solution.test.ts new file mode 100644 index 0000000..b9862bb --- /dev/null +++ b/src/test/ts/g0001_0100/s0061_rotate_list/solution.test.ts @@ -0,0 +1,12 @@ +// tslint:disable:no-magic-numbers +import { rotateRight } from 'src/main/ts/g0001_0100/s0061_rotate_list/solution' +import { expect, test } from 'vitest' +import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils' + +test('rotateRight', () => { + expect(rotateRight(constructLinkedList([1,2,3,4,5]), 2).toString()).toEqual('4, 5, 1, 2, 3') +}) + +test('rotateRight2', () => { + expect(rotateRight(constructLinkedList([0,1,2]), 4).toString()).toEqual('2, 0, 1') +}) diff --git a/src/test/ts/g0001_0100/s0063_unique_paths_ii/solution.test.ts b/src/test/ts/g0001_0100/s0063_unique_paths_ii/solution.test.ts new file mode 100644 index 0000000..2937799 --- /dev/null +++ b/src/test/ts/g0001_0100/s0063_unique_paths_ii/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { uniquePathsWithObstacles } from 'src/main/ts/g0001_0100/s0063_unique_paths_ii/solution' +import { expect, test } from 'vitest' + +test('uniquePathsWithObstacles', () => { + expect(uniquePathsWithObstacles([[0,0,0],[0,1,0],[0,0,0]])).toEqual(2) +}) + +test('uniquePathsWithObstacles2', () => { + expect(uniquePathsWithObstacles([[0,1],[0,0]])).toEqual(1) +}) diff --git a/src/test/ts/g0001_0100/s0066_plus_one/solution.test.ts b/src/test/ts/g0001_0100/s0066_plus_one/solution.test.ts new file mode 100644 index 0000000..fe14396 --- /dev/null +++ b/src/test/ts/g0001_0100/s0066_plus_one/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { plusOne } from 'src/main/ts/g0001_0100/s0066_plus_one/solution' +import { expect, test } from 'vitest' + +test('plusOne', () => { + expect(plusOne([1,2,3])).toEqual([1,2,4]) +}) + +test('plusOne2', () => { + expect(plusOne([4,3,2,1])).toEqual([4,3,2,2]) +}) + +test('plusOne3', () => { + expect(plusOne([9])).toEqual([1,0]) +}) From 6414fe39661bcd907fc8bb635abef5cb2a4a9361 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Wed, 2 Apr 2025 19:05:46 +0300 Subject: [PATCH 22/49] Improved tasks 57-66 --- .../s0057_insert_interval/solution.ts | 2 +- .../s0057_insert_interval/solution.test.ts | 30 +++++++++++++++++-- .../s0061_rotate_list/solution.test.ts | 4 +-- .../s0063_unique_paths_ii/solution.test.ts | 15 ++++++++-- .../s0066_plus_one/solution.test.ts | 6 ++-- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/main/ts/g0001_0100/s0057_insert_interval/solution.ts b/src/main/ts/g0001_0100/s0057_insert_interval/solution.ts index 1af2bd4..c68e94d 100644 --- a/src/main/ts/g0001_0100/s0057_insert_interval/solution.ts +++ b/src/main/ts/g0001_0100/s0057_insert_interval/solution.ts @@ -17,7 +17,7 @@ function insert(intervals: number[][], newInterval: number[]): number[][] { } res[l] = [ Math.min(newInterval[0], l === n ? newInterval[0] : intervals[l][0]), - Math.max(newInterval[1], r === -1 ? newInterval[1] : intervals[r][1]) + Math.max(newInterval[1], r === -1 ? newInterval[1] : intervals[r][1]), ] for (let i = l + 1, j = r + 1; j < n; i++, j++) { res[i] = intervals[j] diff --git a/src/test/ts/g0001_0100/s0057_insert_interval/solution.test.ts b/src/test/ts/g0001_0100/s0057_insert_interval/solution.test.ts index 614db04..5dc4062 100644 --- a/src/test/ts/g0001_0100/s0057_insert_interval/solution.test.ts +++ b/src/test/ts/g0001_0100/s0057_insert_interval/solution.test.ts @@ -3,9 +3,35 @@ import { insert } from 'src/main/ts/g0001_0100/s0057_insert_interval/solution' import { expect, test } from 'vitest' test('insert', () => { - expect(insert([[1,3],[6,9]], [2,5])).toEqual([[1,5],[6,9]]) + expect( + insert( + [ + [1, 3], + [6, 9], + ], + [2, 5], + ), + ).toEqual([ + [1, 5], + [6, 9], + ]) }) test('insert2', () => { - expect(insert( [[1,2],[3,5],[6,7],[8,10],[12,16]], [4,8])).toEqual([[1,2],[3,10],[12,16]]) + expect( + insert( + [ + [1, 2], + [3, 5], + [6, 7], + [8, 10], + [12, 16], + ], + [4, 8], + ), + ).toEqual([ + [1, 2], + [3, 10], + [12, 16], + ]) }) diff --git a/src/test/ts/g0001_0100/s0061_rotate_list/solution.test.ts b/src/test/ts/g0001_0100/s0061_rotate_list/solution.test.ts index b9862bb..7fa2109 100644 --- a/src/test/ts/g0001_0100/s0061_rotate_list/solution.test.ts +++ b/src/test/ts/g0001_0100/s0061_rotate_list/solution.test.ts @@ -4,9 +4,9 @@ import { expect, test } from 'vitest' import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils' test('rotateRight', () => { - expect(rotateRight(constructLinkedList([1,2,3,4,5]), 2).toString()).toEqual('4, 5, 1, 2, 3') + expect(rotateRight(constructLinkedList([1, 2, 3, 4, 5]), 2).toString()).toEqual('4, 5, 1, 2, 3') }) test('rotateRight2', () => { - expect(rotateRight(constructLinkedList([0,1,2]), 4).toString()).toEqual('2, 0, 1') + expect(rotateRight(constructLinkedList([0, 1, 2]), 4).toString()).toEqual('2, 0, 1') }) diff --git a/src/test/ts/g0001_0100/s0063_unique_paths_ii/solution.test.ts b/src/test/ts/g0001_0100/s0063_unique_paths_ii/solution.test.ts index 2937799..dde6cd1 100644 --- a/src/test/ts/g0001_0100/s0063_unique_paths_ii/solution.test.ts +++ b/src/test/ts/g0001_0100/s0063_unique_paths_ii/solution.test.ts @@ -3,9 +3,20 @@ import { uniquePathsWithObstacles } from 'src/main/ts/g0001_0100/s0063_unique_pa import { expect, test } from 'vitest' test('uniquePathsWithObstacles', () => { - expect(uniquePathsWithObstacles([[0,0,0],[0,1,0],[0,0,0]])).toEqual(2) + expect( + uniquePathsWithObstacles([ + [0, 0, 0], + [0, 1, 0], + [0, 0, 0], + ]), + ).toEqual(2) }) test('uniquePathsWithObstacles2', () => { - expect(uniquePathsWithObstacles([[0,1],[0,0]])).toEqual(1) + expect( + uniquePathsWithObstacles([ + [0, 1], + [0, 0], + ]), + ).toEqual(1) }) diff --git a/src/test/ts/g0001_0100/s0066_plus_one/solution.test.ts b/src/test/ts/g0001_0100/s0066_plus_one/solution.test.ts index fe14396..3b4ec47 100644 --- a/src/test/ts/g0001_0100/s0066_plus_one/solution.test.ts +++ b/src/test/ts/g0001_0100/s0066_plus_one/solution.test.ts @@ -3,13 +3,13 @@ import { plusOne } from 'src/main/ts/g0001_0100/s0066_plus_one/solution' import { expect, test } from 'vitest' test('plusOne', () => { - expect(plusOne([1,2,3])).toEqual([1,2,4]) + expect(plusOne([1, 2, 3])).toEqual([1, 2, 4]) }) test('plusOne2', () => { - expect(plusOne([4,3,2,1])).toEqual([4,3,2,2]) + expect(plusOne([4, 3, 2, 1])).toEqual([4, 3, 2, 2]) }) test('plusOne3', () => { - expect(plusOne([9])).toEqual([1,0]) + expect(plusOne([9])).toEqual([1, 0]) }) From 9f7d77cab638d3bf586c6597c3c1fadbbf0829a0 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Sat, 5 Apr 2025 12:59:37 +0700 Subject: [PATCH 23/49] Added tasks 67-77 --- README.md | 13 +++++ .../ts/g0001_0100/s0067_add_binary/readme.md | 23 ++++++++ .../g0001_0100/s0067_add_binary/solution.ts | 26 +++++++++ .../s0068_text_justification/readme.md | 45 +++++++++++++++ .../s0068_text_justification/solution.ts | 56 +++++++++++++++++++ src/main/ts/g0001_0100/s0069_sqrtx/readme.md | 28 ++++++++++ .../ts/g0001_0100/s0069_sqrtx/solution.ts | 23 ++++++++ .../g0001_0100/s0071_simplify_path/readme.md | 52 +++++++++++++++++ .../s0071_simplify_path/solution.ts | 19 +++++++ .../g0001_0100/s0077_combinations/readme.md | 24 ++++++++ .../g0001_0100/s0077_combinations/solution.ts | 21 +++++++ .../s0067_add_binary/solution.test.ts | 11 ++++ .../s0068_text_justification/solution.test.ts | 30 ++++++++++ .../g0001_0100/s0069_sqrtx/solution.test.ts | 11 ++++ .../s0071_simplify_path/solution.test.ts | 23 ++++++++ .../s0077_combinations/solution.test.ts | 11 ++++ 16 files changed, 416 insertions(+) create mode 100644 src/main/ts/g0001_0100/s0067_add_binary/readme.md create mode 100644 src/main/ts/g0001_0100/s0067_add_binary/solution.ts create mode 100644 src/main/ts/g0001_0100/s0068_text_justification/readme.md create mode 100644 src/main/ts/g0001_0100/s0068_text_justification/solution.ts create mode 100644 src/main/ts/g0001_0100/s0069_sqrtx/readme.md create mode 100644 src/main/ts/g0001_0100/s0069_sqrtx/solution.ts create mode 100644 src/main/ts/g0001_0100/s0071_simplify_path/readme.md create mode 100644 src/main/ts/g0001_0100/s0071_simplify_path/solution.ts create mode 100644 src/main/ts/g0001_0100/s0077_combinations/readme.md create mode 100644 src/main/ts/g0001_0100/s0077_combinations/solution.ts create mode 100644 src/test/ts/g0001_0100/s0067_add_binary/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0068_text_justification/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0069_sqrtx/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0071_simplify_path/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0077_combinations/solution.test.ts diff --git a/README.md b/README.md index cc3be26..892fe2c 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Hard | Array, String, Simulation | 0 | 100.00 #### Day 5 @@ -418,6 +419,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0067 |[Add Binary](src/main/ts/g0001_0100/s0067_add_binary/solution.ts)| Easy | String, Math, Bit_Manipulation, Simulation | 0 | 100.00 #### Day 6 @@ -1018,6 +1020,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0014 |[Longest Common Prefix](src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String | 0 | 100.00 | 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 2 | 99.08 | 0028 |[Implement strStr()](src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 +| 0068 |[Text Justification](src/main/ts/g0001_0100/s0068_text_justification/solution.ts)| Hard | Array, String, Simulation | 0 | 100.00 #### Top Interview 150 Two Pointers @@ -1063,6 +1066,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 +| 0071 |[Simplify Path](src/main/ts/g0001_0100/s0071_simplify_path/solution.ts)| Medium | String, Stack | 0 | 100.00 | 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 #### Top Interview 150 Linked List @@ -1126,6 +1130,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0077 |[Combinations](src/main/ts/g0001_0100/s0077_combinations/solution.ts)| Medium | Backtracking | 46 | 96.14 | 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 | 0052 |[N-Queens II](src/main/ts/g0001_0100/s0052_n_queens_ii/solution.ts)| Hard | Backtracking | 1 | 96.89 @@ -1167,6 +1172,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0067 |[Add Binary](src/main/ts/g0001_0100/s0067_add_binary/solution.ts)| Easy | String, Math, Bit_Manipulation, Simulation | 0 | 100.00 | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 #### Top Interview 150 Math @@ -1175,6 +1181,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 +| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Hard | Array, String, Simulation | 0 | 100.00 | 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 #### Top Interview 150 1D DP @@ -1477,6 +1484,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0077 |[Combinations](src/main/ts/g0001_0100/s0077_combinations/solution.ts)| Medium | Backtracking | 46 | 96.14 | 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 #### Day 12 Dynamic Programming @@ -1690,12 +1698,17 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0084 |[Largest Rectangle in Histogram](src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n_log_n)_Space_O(log_n) | 15 | 72.81 | 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Top_Interview_150_Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 243 | 85.30 | 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Algorithm_II_Day_9_Recursion_Backtracking, Udemy_Backtracking/Recursion, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 +| 0077 |[Combinations](src/main/ts/g0001_0100/s0077_combinations/solution.ts)| Medium | Backtracking, Algorithm_I_Day_11_Recursion_Backtracking, Top_Interview_150_Backtracking | 46 | 96.14 | 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Top_Interview_150_Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 20 | 90.35 | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_2_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Data_Structure_I_Day_5_Array, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_8, Level_2_Day_8_Binary_Search, Udemy_2D_Arrays/Matrix, Top_Interview_150_Binary_Search, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 | 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 4 | 50.63 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 +| 0071 |[Simplify Path](src/main/ts/g0001_0100/s0071_simplify_path/solution.ts)| Medium | String, Stack, Top_Interview_150_Stack | 0 | 100.00 | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_2, Level_1_Day_10_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Hard | Array, String, Simulation, Top_Interview_150_Array/String | 0 | 100.00 +| 0068 |[Text Justification](src/main/ts/g0001_0100/s0068_text_justification/solution.ts)| Hard | Array, String, Simulation, Top_Interview_150_Array/String | 0 | 100.00 +| 0067 |[Add Binary](src/main/ts/g0001_0100/s0067_add_binary/solution.ts)| Easy | String, Math, Bit_Manipulation, Simulation, Programming_Skills_II_Day_5, Top_Interview_150_Bit_Manipulation | 0 | 100.00 | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math, Programming_Skills_II_Day_3, Udemy_Arrays, Top_Interview_150_Math | 0 | 100.00 | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0063 |[Unique Paths II](src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_15, Top_Interview_150_Multidimensional_DP | 0 | 100.00 diff --git a/src/main/ts/g0001_0100/s0067_add_binary/readme.md b/src/main/ts/g0001_0100/s0067_add_binary/readme.md new file mode 100644 index 0000000..e47d02c --- /dev/null +++ b/src/main/ts/g0001_0100/s0067_add_binary/readme.md @@ -0,0 +1,23 @@ +67\. Add Binary + +Easy + +Given two binary strings `a` and `b`, return _their sum as a binary string_. + +**Example 1:** + +**Input:** a = "11", b = "1" + +**Output:** "100" + +**Example 2:** + +**Input:** a = "1010", b = "1011" + +**Output:** "10101" + +**Constraints:** + +* 1 <= a.length, b.length <= 104 +* `a` and `b` consist only of `'0'` or `'1'` characters. +* Each string does not contain leading zeros except for the zero itself. diff --git a/src/main/ts/g0001_0100/s0067_add_binary/solution.ts b/src/main/ts/g0001_0100/s0067_add_binary/solution.ts new file mode 100644 index 0000000..bfcc3ae --- /dev/null +++ b/src/main/ts/g0001_0100/s0067_add_binary/solution.ts @@ -0,0 +1,26 @@ +// #Easy #String #Math #Bit_Manipulation #Simulation #Programming_Skills_II_Day_5 +// #Top_Interview_150_Bit_Manipulation #2025_04_05_Time_0_ms_(100.00%)_Space_58.14_MB_(39.81%) + +function addBinary(a: string, b: string): string { + const aArray = a.split('') + const bArray = b.split('') + let sb: string[] = [] + let i = aArray.length - 1 + let j = bArray.length - 1 + let carry = 0 + while (i >= 0 || j >= 0) { + const digitA = i >= 0 ? parseInt(aArray[i]) : 0 + const digitB = j >= 0 ? parseInt(bArray[j]) : 0 + const sum = digitA + digitB + carry + sb.push((sum % 2).toString()) + carry = Math.floor(sum / 2) + i-- + j-- + } + if (carry !== 0) { + sb.push(carry.toString()) + } + return sb.reverse().join('') +} + +export { addBinary } diff --git a/src/main/ts/g0001_0100/s0068_text_justification/readme.md b/src/main/ts/g0001_0100/s0068_text_justification/readme.md new file mode 100644 index 0000000..1f62373 --- /dev/null +++ b/src/main/ts/g0001_0100/s0068_text_justification/readme.md @@ -0,0 +1,45 @@ +68\. Text Justification + +Hard + +Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified. + +You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that each line has exactly `maxWidth` characters. + +Extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line does not divide evenly between words, the empty slots on the left will be assigned more spaces than the slots on the right. + +For the last line of text, it should be left-justified and no extra space is inserted between words. + +**Note:** + +* A word is defined as a character sequence consisting of non-space characters only. +* Each word's length is guaranteed to be greater than 0 and not exceed maxWidth. +* The input array `words` contains at least one word. + +**Example 1:** + +**Input:** words = ["This", "is", "an", "example", "of", "text", "justification."], maxWidth = 16 + +**Output:** [ "This is an", "example of text", "justification. " ] + +**Example 2:** + +**Input:** words = ["What","must","be","acknowledgment","shall","be"], maxWidth = 16 + +**Output:** [ "What must be", "acknowledgment ", "shall be " ] + +**Explanation:** Note that the last line is "shall be " instead of "shall be", because the last line must be left-justified instead of fully-justified. Note that the second line is also left-justified becase it contains only one word. + +**Example 3:** + +**Input:** words = ["Science","is","what","we","understand","well","enough","to","explain","to","a","computer.","Art","is","everything","else","we","do"], maxWidth = 20 + +**Output:** [ "Science is what we", "understand well", "enough to explain to", "a computer. Art is", "everything else we", "do " ] + +**Constraints:** + +* `1 <= words.length <= 300` +* `1 <= words[i].length <= 20` +* `words[i]` consists of only English letters and symbols. +* `1 <= maxWidth <= 100` +* `words[i].length <= maxWidth` diff --git a/src/main/ts/g0001_0100/s0068_text_justification/solution.ts b/src/main/ts/g0001_0100/s0068_text_justification/solution.ts new file mode 100644 index 0000000..ed43ef6 --- /dev/null +++ b/src/main/ts/g0001_0100/s0068_text_justification/solution.ts @@ -0,0 +1,56 @@ +// #Hard #Array #String #Simulation #Top_Interview_150_Array/String +// #2025_04_05_Time_0_ms_(100.00%)_Space_55.70_MB_(38.14%) + +function fullJustify(words: string[], maxWidth: number): string[] { + const output: string[] = [] + let sb: string[] = [] + let lineTotal = 0 + let numWordsOnLine = 0 + let startWord = 0 + for (let i = 0; i < words.length - 1; i++) { + lineTotal += words[i].length + numWordsOnLine++ + if (lineTotal + numWordsOnLine + words[i + 1].length > maxWidth) { + sb = [] + if (numWordsOnLine === 1) { + sb.push(words[i]) + while (lineTotal++ < maxWidth) { + sb.push(' ') + } + } else { + const spaces = Math.floor((maxWidth - lineTotal) / (numWordsOnLine - 1)) + let extraSp = (maxWidth - lineTotal) % (numWordsOnLine - 1) + + for (let j = startWord; j < startWord + numWordsOnLine - 1; j++) { + sb.push(words[j]) + sb.push(' '.repeat(spaces + (extraSp-- > 0 ? 1 : 0))) + } + sb.push(words[startWord + numWordsOnLine - 1]) + } + output.push(sb.join('')) + startWord = i + 1 + numWordsOnLine = lineTotal = 0 + } + } + + // Handle last line + sb = [] + lineTotal = 0 + for (let i = startWord; i < words.length; i++) { + lineTotal += words[i].length + sb.push(words[i]) + if (lineTotal < maxWidth) { + sb.push(' ') + lineTotal++ + } + } + while (lineTotal < maxWidth) { + sb.push(' ') + lineTotal++ + } + output.push(sb.join('')) + + return output +} + +export { fullJustify } diff --git a/src/main/ts/g0001_0100/s0069_sqrtx/readme.md b/src/main/ts/g0001_0100/s0069_sqrtx/readme.md new file mode 100644 index 0000000..38b7950 --- /dev/null +++ b/src/main/ts/g0001_0100/s0069_sqrtx/readme.md @@ -0,0 +1,28 @@ +69\. Sqrt(x) + +Easy + +Given a non-negative integer `x`, compute and return _the square root of_ `x`. + +Since the return type is an integer, the decimal digits are **truncated**, and only **the integer part** of the result is returned. + +**Note:** You are not allowed to use any built-in exponent function or operator, such as `pow(x, 0.5)` or `x ** 0.5`. + +**Example 1:** + +**Input:** x = 4 + +**Output:** 2 + +**Example 2:** + +**Input:** x = 8 + +**Output:** 2 + +**Explanation:** The square root of 8 is 2.82842..., and since the decimal part is truncated, 2 is returned. + +**Constraints:** + +* 0 <= x <= 231 - 1 + diff --git a/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts b/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts new file mode 100644 index 0000000..8ce3a43 --- /dev/null +++ b/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts @@ -0,0 +1,23 @@ +// #Hard #Array #String #Simulation #Top_Interview_150_Array/String +// #2025_04_05_Time_0_ms_(100.00%)_Space_55.70_MB_(38.14%) + +function mySqrt(x: number): number { + let low = 1 + let high = x + let lowest = 0 + while (low <= high) { + const mid = Math.floor((low + high) / 2) + const pow = mid * mid + if(pow > x) { + high = mid - 1 + } else if(pow < x) { + low = mid + 1 + lowest = mid + } else { + return mid + } + } + return lowest +} + +export { mySqrt } diff --git a/src/main/ts/g0001_0100/s0071_simplify_path/readme.md b/src/main/ts/g0001_0100/s0071_simplify_path/readme.md new file mode 100644 index 0000000..1724575 --- /dev/null +++ b/src/main/ts/g0001_0100/s0071_simplify_path/readme.md @@ -0,0 +1,52 @@ +71\. Simplify Path + +Medium + +Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**. + +In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level, and any multiple consecutive slashes (i.e. `'//'`) are treated as a single slash `'/'`. For this problem, any other format of periods such as `'...'` are treated as file/directory names. + +The **canonical path** should have the following format: + +* The path starts with a single slash `'/'`. +* Any two directories are separated by a single slash `'/'`. +* The path does not end with a trailing `'/'`. +* The path only contains the directories on the path from the root directory to the target file or directory (i.e., no period `'.'` or double period `'..'`) + +Return _the simplified **canonical path**_. + +**Example 1:** + +**Input:** path = "/home/" + +**Output:** "/home" + +**Explanation:** Note that there is no trailing slash after the last directory name. + +**Example 2:** + +**Input:** path = "/../" + +**Output:** "/" + +**Explanation:** Going one level up from the root directory is a no-op, as the root level is the highest level you can go. + +**Example 3:** + +**Input:** path = "/home//foo/" + +**Output:** "/home/foo" + +**Explanation:** In the canonical path, multiple consecutive slashes are replaced by a single one. + +**Example 4:** + +**Input:** path = "/a/./b/../../c/" + +**Output:** "/c" + +**Constraints:** + +* `1 <= path.length <= 3000` +* `path` consists of English letters, digits, period `'.'`, slash `'/'` or `'_'`. +* `path` is a valid absolute Unix path. diff --git a/src/main/ts/g0001_0100/s0071_simplify_path/solution.ts b/src/main/ts/g0001_0100/s0071_simplify_path/solution.ts new file mode 100644 index 0000000..60bf7fa --- /dev/null +++ b/src/main/ts/g0001_0100/s0071_simplify_path/solution.ts @@ -0,0 +1,19 @@ +// #Medium #String #Stack #Top_Interview_150_Stack +// #2025_04_05_Time_0_ms_(100.00%)_Space_58.31_MB_(30.21%) + +function simplifyPath(path: string): string { + const stack = [] + const mod = path.split('/').filter((element) => element.length) + for (const element of mod) { + if (element === '..') { + stack.pop() + } else if (element === '.') { + continue + } else { + stack.push(element) + } + } + return '/'.concat(stack.join('/')) +} + +export { simplifyPath } diff --git a/src/main/ts/g0001_0100/s0077_combinations/readme.md b/src/main/ts/g0001_0100/s0077_combinations/readme.md new file mode 100644 index 0000000..e6e38ec --- /dev/null +++ b/src/main/ts/g0001_0100/s0077_combinations/readme.md @@ -0,0 +1,24 @@ +77\. Combinations + +Medium + +Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers out of the range_ `[1, n]`. + +You may return the answer in **any order**. + +**Example 1:** + +**Input:** n = 4, k = 2 + +**Output:** [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] + +**Example 2:** + +**Input:** n = 1, k = 1 + +**Output:** [[1]] + +**Constraints:** + +* `1 <= n <= 20` +* `1 <= k <= n` diff --git a/src/main/ts/g0001_0100/s0077_combinations/solution.ts b/src/main/ts/g0001_0100/s0077_combinations/solution.ts new file mode 100644 index 0000000..1745911 --- /dev/null +++ b/src/main/ts/g0001_0100/s0077_combinations/solution.ts @@ -0,0 +1,21 @@ +// #Medium #Backtracking #Algorithm_I_Day_11_Recursion_Backtracking #Top_Interview_150_Backtracking +// #2025_04_05_Time_46_ms_(96.14%)_Space_128.25_MB_(74.09%) + +function combine(n: number, k: number): number[][] { + const ans: number[][] = [] + const backtrack = (curr: number[], j: number) => { + if (curr.length == k) { + ans.push([...curr]) + return + } + for (let i = j; i <= n; i++) { + curr.push(i) + backtrack(curr, i + 1) + curr.pop() + } + } + backtrack([], 1) + return ans +} + +export { combine } diff --git a/src/test/ts/g0001_0100/s0067_add_binary/solution.test.ts b/src/test/ts/g0001_0100/s0067_add_binary/solution.test.ts new file mode 100644 index 0000000..b6c5ce3 --- /dev/null +++ b/src/test/ts/g0001_0100/s0067_add_binary/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { addBinary } from 'src/main/ts/g0001_0100/s0067_add_binary/solution' +import { expect, test } from 'vitest' + +test('addBinary', () => { + expect(addBinary('11', '1')).toEqual('100') +}) + +test('addBinary2', () => { + expect(addBinary('1010', '1011')).toEqual('10101') +}) diff --git a/src/test/ts/g0001_0100/s0068_text_justification/solution.test.ts b/src/test/ts/g0001_0100/s0068_text_justification/solution.test.ts new file mode 100644 index 0000000..b4413e8 --- /dev/null +++ b/src/test/ts/g0001_0100/s0068_text_justification/solution.test.ts @@ -0,0 +1,30 @@ +// tslint:disable:no-magic-numbers +import { fullJustify } from 'src/main/ts/g0001_0100/s0068_text_justification/solution' +import { expect, test } from 'vitest' + +test('fullJustify', () => { + expect(fullJustify(['This', 'is', 'an', 'example', 'of', 'text', 'justification.'], 16)).toEqual([ + 'This is an', + 'example of text', + 'justification. ' + ]) +}) + +test('fullJustify2', () => { + expect(fullJustify(['What','must','be','acknowledgment','shall','be'], 16)).toEqual([ + 'What must be', + 'acknowledgment ', + 'shall be ' + ]) +}) + +test('fullJustify3', () => { + expect(fullJustify(['Science','is','what','we','understand','well','enough','to','explain','to','a','computer.','Art','is','everything','else','we','do'], 20)).toEqual([ + 'Science is what we', + 'understand well', + 'enough to explain to', + 'a computer. Art is', + 'everything else we', + 'do ' + ]) +}) diff --git a/src/test/ts/g0001_0100/s0069_sqrtx/solution.test.ts b/src/test/ts/g0001_0100/s0069_sqrtx/solution.test.ts new file mode 100644 index 0000000..15cf769 --- /dev/null +++ b/src/test/ts/g0001_0100/s0069_sqrtx/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { mySqrt } from 'src/main/ts/g0001_0100/s0069_sqrtx/solution' +import { expect, test } from 'vitest' + +test('mySqrt', () => { + expect(mySqrt(4)).toEqual(2) +}) + +test('mySqrt2', () => { + expect(mySqrt(8)).toEqual(2) +}) diff --git a/src/test/ts/g0001_0100/s0071_simplify_path/solution.test.ts b/src/test/ts/g0001_0100/s0071_simplify_path/solution.test.ts new file mode 100644 index 0000000..9e9bcd9 --- /dev/null +++ b/src/test/ts/g0001_0100/s0071_simplify_path/solution.test.ts @@ -0,0 +1,23 @@ +// tslint:disable:no-magic-numbers +import { simplifyPath } from 'src/main/ts/g0001_0100/s0071_simplify_path/solution' +import { expect, test } from 'vitest' + +test('simplifyPath', () => { + expect(simplifyPath('/home/')).toEqual('/home') +}) + +test('simplifyPath2', () => { + expect(simplifyPath('/home//foo/')).toEqual('/home/foo') +}) + +test('simplifyPath3', () => { + expect(simplifyPath('/home/user/Documents/../Pictures')).toEqual('/home/user/Pictures') +}) + +test('simplifyPath4', () => { + expect(simplifyPath('/../')).toEqual('/') +}) + +test('simplifyPath5', () => { + expect(simplifyPath('/.../a/../b/c/../d/./')).toEqual('/.../b/d') +}) diff --git a/src/test/ts/g0001_0100/s0077_combinations/solution.test.ts b/src/test/ts/g0001_0100/s0077_combinations/solution.test.ts new file mode 100644 index 0000000..e8b5fea --- /dev/null +++ b/src/test/ts/g0001_0100/s0077_combinations/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { combine } from 'src/main/ts/g0001_0100/s0077_combinations/solution' +import { expect, test } from 'vitest' + +test('combine', () => { + expect(combine(4, 2)).toEqual([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]) +}) + +test('combine2', () => { + expect(combine(1, 1)).toEqual([[1]]) +}) From eb5fdc74f2a9d96f50e0a1430340e8442a84ad62 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sat, 5 Apr 2025 09:52:05 +0300 Subject: [PATCH 24/49] Improved tasks 68, 69, 77 --- .../ts/g0001_0100/s0069_sqrtx/solution.ts | 4 +- .../s0068_text_justification/solution.test.ts | 58 +++++++++++++------ .../s0077_combinations/solution.test.ts | 9 ++- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts b/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts index 8ce3a43..4d29882 100644 --- a/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts +++ b/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts @@ -8,9 +8,9 @@ function mySqrt(x: number): number { while (low <= high) { const mid = Math.floor((low + high) / 2) const pow = mid * mid - if(pow > x) { + if (pow > x) { high = mid - 1 - } else if(pow < x) { + } else if (pow < x) { low = mid + 1 lowest = mid } else { diff --git a/src/test/ts/g0001_0100/s0068_text_justification/solution.test.ts b/src/test/ts/g0001_0100/s0068_text_justification/solution.test.ts index b4413e8..3333d34 100644 --- a/src/test/ts/g0001_0100/s0068_text_justification/solution.test.ts +++ b/src/test/ts/g0001_0100/s0068_text_justification/solution.test.ts @@ -4,27 +4,51 @@ import { expect, test } from 'vitest' test('fullJustify', () => { expect(fullJustify(['This', 'is', 'an', 'example', 'of', 'text', 'justification.'], 16)).toEqual([ - 'This is an', - 'example of text', - 'justification. ' - ]) + 'This is an', + 'example of text', + 'justification. ', + ]) }) test('fullJustify2', () => { - expect(fullJustify(['What','must','be','acknowledgment','shall','be'], 16)).toEqual([ - 'What must be', - 'acknowledgment ', - 'shall be ' - ]) + expect(fullJustify(['What', 'must', 'be', 'acknowledgment', 'shall', 'be'], 16)).toEqual([ + 'What must be', + 'acknowledgment ', + 'shall be ', + ]) }) test('fullJustify3', () => { - expect(fullJustify(['Science','is','what','we','understand','well','enough','to','explain','to','a','computer.','Art','is','everything','else','we','do'], 20)).toEqual([ - 'Science is what we', - 'understand well', - 'enough to explain to', - 'a computer. Art is', - 'everything else we', - 'do ' - ]) + expect( + fullJustify( + [ + 'Science', + 'is', + 'what', + 'we', + 'understand', + 'well', + 'enough', + 'to', + 'explain', + 'to', + 'a', + 'computer.', + 'Art', + 'is', + 'everything', + 'else', + 'we', + 'do', + ], + 20, + ), + ).toEqual([ + 'Science is what we', + 'understand well', + 'enough to explain to', + 'a computer. Art is', + 'everything else we', + 'do ', + ]) }) diff --git a/src/test/ts/g0001_0100/s0077_combinations/solution.test.ts b/src/test/ts/g0001_0100/s0077_combinations/solution.test.ts index e8b5fea..b548d1e 100644 --- a/src/test/ts/g0001_0100/s0077_combinations/solution.test.ts +++ b/src/test/ts/g0001_0100/s0077_combinations/solution.test.ts @@ -3,7 +3,14 @@ import { combine } from 'src/main/ts/g0001_0100/s0077_combinations/solution' import { expect, test } from 'vitest' test('combine', () => { - expect(combine(4, 2)).toEqual([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]) + expect(combine(4, 2)).toEqual([ + [1, 2], + [1, 3], + [1, 4], + [2, 3], + [2, 4], + [3, 4], + ]) }) test('combine2', () => { From 7750bed1834bde1f11b8fb18857eb571f03812bb Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Sat, 5 Apr 2025 18:13:27 +0700 Subject: [PATCH 25/49] Added tasks 80-92 --- README.md | 14 ++++++ .../readme.md | 49 +++++++++++++++++++ .../solution.ts | 25 ++++++++++ .../readme.md | 27 ++++++++++ .../solution.ts | 42 ++++++++++++++++ .../g0001_0100/s0086_partition_list/readme.md | 27 ++++++++++ .../s0086_partition_list/solution.ts | 38 ++++++++++++++ .../s0088_merge_sorted_array/readme.md | 43 ++++++++++++++++ .../s0088_merge_sorted_array/solution.ts | 20 ++++++++ .../s0092_reverse_linked_list_ii/readme.md | 28 +++++++++++ .../s0092_reverse_linked_list_ii/solution.ts | 49 +++++++++++++++++++ .../solution.test.ts | 11 +++++ .../solution.test.ts | 12 +++++ .../s0086_partition_list/solution.test.ts | 12 +++++ .../s0088_merge_sorted_array/solution.test.ts | 21 ++++++++ .../solution.test.ts | 12 +++++ 16 files changed, 430 insertions(+) create mode 100644 src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/readme.md create mode 100644 src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.ts create mode 100644 src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/readme.md create mode 100644 src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.ts create mode 100644 src/main/ts/g0001_0100/s0086_partition_list/readme.md create mode 100644 src/main/ts/g0001_0100/s0086_partition_list/solution.ts create mode 100644 src/main/ts/g0001_0100/s0088_merge_sorted_array/readme.md create mode 100644 src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts create mode 100644 src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/readme.md create mode 100644 src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.ts create mode 100644 src/test/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0086_partition_list/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0088_merge_sorted_array/solution.test.ts create mode 100644 src/test/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.test.ts diff --git a/README.md b/README.md index 892fe2c..c7eb371 100644 --- a/README.md +++ b/README.md @@ -883,6 +883,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String | 0 | 100.00 +| 0080 |[Remove Duplicates from Sorted Array II](src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.ts)| Medium | Array, Two_Pointers | 40 | 99.63 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 @@ -1005,8 +1006,10 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0088 |[Merge Sorted Array](src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 | 0027 |[Remove Element](src/main/ts/g0001_0100/s0027_remove_element/solution.ts)| Easy | Array, Two_Pointers | 0 | 100.00 | 0026 |[Remove Duplicates from Sorted Array](src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 +| 0080 |[Remove Duplicates from Sorted Array II](src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.ts)| Medium | Array, Two_Pointers | 40 | 99.63 | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 @@ -1077,9 +1080,12 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0002 |[Add Two Numbers](src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 2 | 95.82 | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 | 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 49 | 72.42 +| 0092 |[Reverse Linked List II](src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.ts)| Medium | Linked_List | 0 | 100.00 | 0025 |[Reverse Nodes in k-Group](src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution.ts)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 | 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 +| 0082 |[Remove Duplicates from Sorted List II](src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 | 0061 |[Rotate List](src/main/ts/g0001_0100/s0061_rotate_list/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0086 |[Partition List](src/main/ts/g0001_0100/s0086_partition_list/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 | 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 97 | 81.52 #### Top Interview 150 Binary Tree General @@ -1217,6 +1223,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 +| 0088 |[Merge Sorted Array](src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 #### Day 3 Array @@ -1362,6 +1369,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 65 | 72.36 +| 0082 |[Remove Duplicates from Sorted List II](src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 #### Day 12 Linked List @@ -1525,6 +1533,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0082 |[Remove Duplicates from Sorted List II](src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 #### Day 4 Two Pointers @@ -1695,7 +1704,12 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_I_Day_14_Tree, Level_1_Day_8_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Dynamic_Programming_I_Day_11, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Data_Structure_I_Day_10_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0092 |[Reverse Linked List II](src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.ts)| Medium | Linked_List, Top_Interview_150_Linked_List | 0 | 100.00 +| 0088 |[Merge Sorted Array](src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts)| Medium | Two_Pointers, Linked_List, Top_Interview_150_Linked_List | 0 | 100.00 +| 0086 |[Partition List](src/main/ts/g0001_0100/s0086_partition_list/solution.ts)| Medium | Two_Pointers, Linked_List, Top_Interview_150_Linked_List | 0 | 100.00 | 0084 |[Largest Rectangle in Histogram](src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n_log_n)_Space_O(log_n) | 15 | 72.81 +| 0082 |[Remove Duplicates from Sorted List II](src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.ts)| Medium | Two_Pointers, Linked_List, Data_Structure_II_Day_11_Linked_List, Algorithm_II_Day_3_Two_Pointers, Top_Interview_150_Linked_List | 0 | 100.00 +| 0080 |[Remove Duplicates from Sorted Array II](src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.ts)| Medium | Array, Two_Pointers, Udemy_Arrays, Top_Interview_150_Array/String | 40 | 99.63 | 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Top_Interview_150_Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 243 | 85.30 | 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Algorithm_II_Day_9_Recursion_Backtracking, Udemy_Backtracking/Recursion, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 | 0077 |[Combinations](src/main/ts/g0001_0100/s0077_combinations/solution.ts)| Medium | Backtracking, Algorithm_I_Day_11_Recursion_Backtracking, Top_Interview_150_Backtracking | 46 | 96.14 diff --git a/src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/readme.md b/src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/readme.md new file mode 100644 index 0000000..36e2637 --- /dev/null +++ b/src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/readme.md @@ -0,0 +1,49 @@ +80\. Remove Duplicates from Sorted Array II + +Medium + +Given an integer array `nums` sorted in **non-decreasing order**, remove some duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears **at most twice**. The **relative order** of the elements should be kept the **same**. + +Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the **first part** of the array `nums`. More formally, if there are `k` elements after removing the duplicates, then the first `k` elements of `nums` should hold the final result. It does not matter what you leave beyond the first `k` elements. + +Return `k` _after placing the final result in the first_ `k` _slots of_ `nums`. + +Do **not** allocate extra space for another array. You must do this by **modifying the input array [in-place](https://en.wikipedia.org/wiki/In-place_algorithm)** with O(1) extra memory. + +**Custom Judge:** + +The judge will test your solution with the following code: + + int[] nums = [...]; // Input array + int[] expectedNums = [...]; // The expected answer with correct length + + int k = removeDuplicates(nums); // Calls your implementation + + assert k == expectedNums.length; + for (int i = 0; i < k; i++) { + assert nums[i] == expectedNums[i]; + } + +If all assertions pass, then your solution will be **accepted**. + +**Example 1:** + +**Input:** nums = [1,1,1,2,2,3] + +**Output:** 5, nums = [1,1,2,2,3,\_] + +**Explanation:** Your function should return k = 5, with the first five elements of nums being 1, 1, 2, 2 and 3 respectively. It does not matter what you leave beyond the returned k (hence they are underscores). + +**Example 2:** + +**Input:** nums = [0,0,1,1,1,1,2,3,3] + +**Output:** 7, nums = [0,0,1,1,2,3,3,\_,\_] + +**Explanation:** Your function should return k = 7, with the first seven elements of nums being 0, 0, 1, 1, 2, 3 and 3 respectively. It does not matter what you leave beyond the returned k (hence they are underscores). + +**Constraints:** + +* 1 <= nums.length <= 3 * 104 +* -104 <= nums[i] <= 104 +* `nums` is sorted in **non-decreasing** order. diff --git a/src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.ts b/src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.ts new file mode 100644 index 0000000..018d236 --- /dev/null +++ b/src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.ts @@ -0,0 +1,25 @@ +// #Medium #Array #Two_Pointers #Udemy_Arrays #Top_Interview_150_Array/String +// #2025_04_05_Time_40_ms_(99.63%)_Space_59.84_MB_(30.62%) + +function removeDuplicates(nums: number[]): number { + let i = 0 + let k = 0 + let count = 0 + while (i < nums.length - 1) { + count++ + if (count <= 2) { + nums[k++] = nums[i] + } + if (nums[i] !== nums[i + 1]) { + count = 0 + } + i++ + } + count++ + if (count <= 2) { + nums[k++] = nums[i] + } + return k +} + +export { removeDuplicates } diff --git a/src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/readme.md b/src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/readme.md new file mode 100644 index 0000000..c5d55ac --- /dev/null +++ b/src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/readme.md @@ -0,0 +1,27 @@ +82\. Remove Duplicates from Sorted List II + +Medium + +Given the `head` of a sorted linked list, _delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list_. Return _the linked list **sorted** as well_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/01/04/linkedlist1.jpg) + +**Input:** head = [1,2,3,3,4,4,5] + +**Output:** [1,2,5] + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2021/01/04/linkedlist2.jpg) + +**Input:** head = [1,1,1,2,3] + +**Output:** [2,3] + +**Constraints:** + +* The number of nodes in the list is in the range `[0, 300]`. +* `-100 <= Node.val <= 100` +* The list is guaranteed to be **sorted** in ascending order. diff --git a/src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.ts b/src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.ts new file mode 100644 index 0000000..aac4eee --- /dev/null +++ b/src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.ts @@ -0,0 +1,42 @@ +// #Medium #Two_Pointers #Linked_List #Data_Structure_II_Day_11_Linked_List +// #Algorithm_II_Day_3_Two_Pointers #Top_Interview_150_Linked_List +// #2025_04_05_Time_0_ms_(100.00%)_Space_58.58_MB_(53.51%) + +import { ListNode } from '../../com_github_leetcode/listnode' + +/** + * Definition for singly-linked list. + * class ListNode { + * val: number + * next: ListNode | null + * constructor(val?: number, next?: ListNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.next = (next===undefined ? null : next) + * } + * } + */ +function deleteDuplicates(head: ListNode | null): ListNode | null { + if (!head || !head.next) { + return head + } + const dummy = new ListNode(0) + dummy.next = head + let prev: ListNode = dummy + let curr: ListNode | null = head + while (curr) { + let hasDuplicate = false + while (curr.next && curr.val === curr.next.val) { + hasDuplicate = true + curr = curr.next + } + if (hasDuplicate) { + prev.next = curr.next + } else { + prev = prev.next! + } + curr = curr.next + } + return dummy.next +} + +export { deleteDuplicates } diff --git a/src/main/ts/g0001_0100/s0086_partition_list/readme.md b/src/main/ts/g0001_0100/s0086_partition_list/readme.md new file mode 100644 index 0000000..fd27e77 --- /dev/null +++ b/src/main/ts/g0001_0100/s0086_partition_list/readme.md @@ -0,0 +1,27 @@ +86\. Partition List + +Medium + +Given the `head` of a linked list and a value `x`, partition it such that all nodes **less than** `x` come before nodes **greater than or equal** to `x`. + +You should **preserve** the original relative order of the nodes in each of the two partitions. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/01/04/partition.jpg) + +**Input:** head = [1,4,3,2,5,2], x = 3 + +**Output:** [1,2,2,4,3,5] + +**Example 2:** + +**Input:** head = [2,1], x = 2 + +**Output:** [1,2] + +**Constraints:** + +* The number of nodes in the list is in the range `[0, 200]`. +* `-100 <= Node.val <= 100` +* `-200 <= x <= 200` diff --git a/src/main/ts/g0001_0100/s0086_partition_list/solution.ts b/src/main/ts/g0001_0100/s0086_partition_list/solution.ts new file mode 100644 index 0000000..cbeeff9 --- /dev/null +++ b/src/main/ts/g0001_0100/s0086_partition_list/solution.ts @@ -0,0 +1,38 @@ +// #Medium #Two_Pointers #Linked_List #Top_Interview_150_Linked_List +// #2025_04_05_Time_0_ms_(100.00%)_Space_58.16_MB_(62.07%) + +import { ListNode } from '../../com_github_leetcode/listnode' + +/** + * Definition for singly-linked list. + * class ListNode { + * val: number + * next: ListNode | null + * constructor(val?: number, next?: ListNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.next = (next===undefined ? null : next) + * } + * } + */ +function partition(head: ListNode | null, x: number): ListNode | null { + let beforeHead = new ListNode(0) + let afterHead = new ListNode(0) + let before = beforeHead + let after = afterHead + while (head !== null) { + const nextNode = head.next + if (head.val < x) { + before.next = head + before = before.next + } else { + after.next = head + after = after.next + } + head = nextNode + } + after.next = null + before.next = afterHead.next + return beforeHead.next +} + +export { partition } diff --git a/src/main/ts/g0001_0100/s0088_merge_sorted_array/readme.md b/src/main/ts/g0001_0100/s0088_merge_sorted_array/readme.md new file mode 100644 index 0000000..7656505 --- /dev/null +++ b/src/main/ts/g0001_0100/s0088_merge_sorted_array/readme.md @@ -0,0 +1,43 @@ +88\. Merge Sorted Array + +Easy + +You are given two integer arrays `nums1` and `nums2`, sorted in **non-decreasing order**, and two integers `m` and `n`, representing the number of elements in `nums1` and `nums2` respectively. + +**Merge** `nums1` and `nums2` into a single array sorted in **non-decreasing order**. + +The final sorted array should not be returned by the function, but instead be _stored inside the array_ `nums1`. To accommodate this, `nums1` has a length of `m + n`, where the first `m` elements denote the elements that should be merged, and the last `n` elements are set to `0` and should be ignored. `nums2` has a length of `n`. + +**Example 1:** + +**Input:** nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3 + +**Output:** [1,2,2,3,5,6] + +**Explanation:** The arrays we are merging are [1,2,3] and [2,5,6]. The result of the merge is [1,2,2,3,5,6] with the underlined elements coming from nums1. + +**Example 2:** + +**Input:** nums1 = [1], m = 1, nums2 = [], n = 0 + +**Output:** [1] + +**Explanation:** The arrays we are merging are [1] and []. The result of the merge is [1]. + +**Example 3:** + +**Input:** nums1 = [0], m = 0, nums2 = [1], n = 1 + +**Output:** [1] + +**Explanation:** The arrays we are merging are [] and [1]. The result of the merge is [1]. Note that because m = 0, there are no elements in nums1. The 0 is only there to ensure the merge result can fit in nums1. + +**Constraints:** + +* `nums1.length == m + n` +* `nums2.length == n` +* `0 <= m, n <= 200` +* `1 <= m + n <= 200` +* -109 <= nums1[i], nums2[j] <= 109 + +**Follow up:** Can you come up with an algorithm that runs in `O(m + n)` time? diff --git a/src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts b/src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts new file mode 100644 index 0000000..559a255 --- /dev/null +++ b/src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts @@ -0,0 +1,20 @@ +// #Medium #Two_Pointers #Linked_List #Top_Interview_150_Linked_List +// #2025_04_05_Time_0_ms_(100.00%)_Space_58.16_MB_(62.07%) + +/** + * Do not return anything, modify nums1 in-place instead. + */ +function merge(nums1: number[], m: number, nums2: number[], n: number): void { + let i = m - 1 + let j = nums1.length - 1 + let p2 = n - 1 + while (p2 >= 0) { + if (i >= 0 && nums1[i] > nums2[p2]) { + nums1[j--] = nums1[i--] + } else { + nums1[j--] = nums2[p2--] + } + } +} + +export { merge } diff --git a/src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/readme.md b/src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/readme.md new file mode 100644 index 0000000..d7d7133 --- /dev/null +++ b/src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/readme.md @@ -0,0 +1,28 @@ +92\. Reverse Linked List II + +Medium + +Given the `head` of a singly linked list and two integers `left` and `right` where `left <= right`, reverse the nodes of the list from position `left` to position `right`, and return _the reversed list_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/02/19/rev2ex2.jpg) + +**Input:** head = [1,2,3,4,5], left = 2, right = 4 + +**Output:** [1,4,3,2,5] + +**Example 2:** + +**Input:** head = [5], left = 1, right = 1 + +**Output:** [5] + +**Constraints:** + +* The number of nodes in the list is `n`. +* `1 <= n <= 500` +* `-500 <= Node.val <= 500` +* `1 <= left <= right <= n` + +**Follow up:** Could you do it in one pass? diff --git a/src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.ts b/src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.ts new file mode 100644 index 0000000..41c7ae8 --- /dev/null +++ b/src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.ts @@ -0,0 +1,49 @@ +// #Medium #Linked_List #Top_Interview_150_Linked_List +// #2025_04_05_Time_0_ms_(100.00%)_Space_55.58_MB_(58.46%) + +import { ListNode } from '../../com_github_leetcode/listnode' + +/** + * Definition for singly-linked list. + * class ListNode { + * val: number + * next: ListNode | null + * constructor(val?: number, next?: ListNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.next = (next===undefined ? null : next) + * } + * } + */ +function reverseBetween(head: ListNode | null, left: number, right: number): ListNode | null { + if (left === right || head === null) { + return head + } + let prev: ListNode | null = null + let temp: ListNode | null = head + let k = left + while (temp !== null && k > 1) { + prev = temp + temp = temp.next + k-- + } + const start = temp + let prev1: ListNode | null = null + let tail: ListNode | null = temp + for (let i = 0; i <= right - left && tail !== null; i++) { + const next = tail.next + tail.next = prev1 + prev1 = tail + tail = next + } + if (prev !== null) { + prev.next = prev1 + } else { + head = prev1 + } + if (start !== null) { + start.next = tail + } + return head +} + +export { reverseBetween } diff --git a/src/test/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.test.ts b/src/test/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.test.ts new file mode 100644 index 0000000..56273c0 --- /dev/null +++ b/src/test/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { removeDuplicates } from 'src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution' +import { expect, test } from 'vitest' + +test('removeDuplicates', () => { + expect(removeDuplicates([1,1,1,2,2,3])).toEqual(5) +}) + +test('removeDuplicates2', () => { + expect(removeDuplicates([0,0,1,1,1,1,2,3,3])).toEqual(7) +}) diff --git a/src/test/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.test.ts b/src/test/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.test.ts new file mode 100644 index 0000000..c1e52c7 --- /dev/null +++ b/src/test/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.test.ts @@ -0,0 +1,12 @@ +// tslint:disable:no-magic-numbers +import { deleteDuplicates } from 'src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution' +import { expect, test } from 'vitest' +import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils' + +test('deleteDuplicates', () => { + expect(deleteDuplicates(constructLinkedList([1,2,3,3,4,4,5])).toString()).toEqual('1, 2, 5') +}) + +test('deleteDuplicates2', () => { + expect(deleteDuplicates(constructLinkedList([1,1,1,2,3])).toString()).toEqual('2, 3') +}) diff --git a/src/test/ts/g0001_0100/s0086_partition_list/solution.test.ts b/src/test/ts/g0001_0100/s0086_partition_list/solution.test.ts new file mode 100644 index 0000000..f7f4d40 --- /dev/null +++ b/src/test/ts/g0001_0100/s0086_partition_list/solution.test.ts @@ -0,0 +1,12 @@ +// tslint:disable:no-magic-numbers +import { partition } from 'src/main/ts/g0001_0100/s0086_partition_list/solution' +import { expect, test } from 'vitest' +import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils' + +test('partition', () => { + expect(partition(constructLinkedList([1,4,3,2,5,2]), 3).toString()).toEqual('1, 2, 2, 4, 3, 5') +}) + +test('partition2', () => { + expect(partition(constructLinkedList([2,1]), 2).toString()).toEqual('1, 2') +}) diff --git a/src/test/ts/g0001_0100/s0088_merge_sorted_array/solution.test.ts b/src/test/ts/g0001_0100/s0088_merge_sorted_array/solution.test.ts new file mode 100644 index 0000000..66d8ea3 --- /dev/null +++ b/src/test/ts/g0001_0100/s0088_merge_sorted_array/solution.test.ts @@ -0,0 +1,21 @@ +// tslint:disable:no-magic-numbers +import { merge } from 'src/main/ts/g0001_0100/s0088_merge_sorted_array/solution' +import { expect, test } from 'vitest' + +test('merge', () => { + const nums1 = [1,2,3,0,0,0] + merge(nums1, 3, [2,5,6], 3) + expect(nums1).toEqual([1,2,2,3,5,6]) +}) + +test('merge2', () => { + const nums1 = [1] + merge(nums1, 1, [], 0) + expect(nums1).toEqual([1]) +}) + +test('merge3', () => { + const nums1 = [0] + merge(nums1, 0, [1], 1) + expect(nums1).toEqual([1]) +}) diff --git a/src/test/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.test.ts b/src/test/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.test.ts new file mode 100644 index 0000000..8888d00 --- /dev/null +++ b/src/test/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.test.ts @@ -0,0 +1,12 @@ +// tslint:disable:no-magic-numbers +import { reverseBetween } from 'src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/solution' +import { expect, test } from 'vitest' +import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils' + +test('reverseBetween', () => { + expect(reverseBetween(constructLinkedList([1,2,3,4,5]), 2, 4).toString()).toEqual('1, 4, 3, 2, 5') +}) + +test('reverseBetween2', () => { + expect(reverseBetween(constructLinkedList([5]), 1, 1).toString()).toEqual('5') +}) From bb2cb5175b43d57bb8549bcdcd2ca86b4fe85a7e Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sun, 6 Apr 2025 08:01:19 +0300 Subject: [PATCH 26/49] Improved tasks 80-92 --- .../solution.test.ts | 4 ++-- .../solution.test.ts | 4 ++-- .../ts/g0001_0100/s0086_partition_list/solution.test.ts | 4 ++-- .../ts/g0001_0100/s0088_merge_sorted_array/solution.test.ts | 6 +++--- .../s0092_reverse_linked_list_ii/solution.test.ts | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.test.ts b/src/test/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.test.ts index 56273c0..6a2960c 100644 --- a/src/test/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.test.ts +++ b/src/test/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.test.ts @@ -3,9 +3,9 @@ import { removeDuplicates } from 'src/main/ts/g0001_0100/s0080_remove_duplicates import { expect, test } from 'vitest' test('removeDuplicates', () => { - expect(removeDuplicates([1,1,1,2,2,3])).toEqual(5) + expect(removeDuplicates([1, 1, 1, 2, 2, 3])).toEqual(5) }) test('removeDuplicates2', () => { - expect(removeDuplicates([0,0,1,1,1,1,2,3,3])).toEqual(7) + expect(removeDuplicates([0, 0, 1, 1, 1, 1, 2, 3, 3])).toEqual(7) }) diff --git a/src/test/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.test.ts b/src/test/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.test.ts index c1e52c7..e3a6d05 100644 --- a/src/test/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.test.ts +++ b/src/test/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.test.ts @@ -4,9 +4,9 @@ import { expect, test } from 'vitest' import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils' test('deleteDuplicates', () => { - expect(deleteDuplicates(constructLinkedList([1,2,3,3,4,4,5])).toString()).toEqual('1, 2, 5') + expect(deleteDuplicates(constructLinkedList([1, 2, 3, 3, 4, 4, 5])).toString()).toEqual('1, 2, 5') }) test('deleteDuplicates2', () => { - expect(deleteDuplicates(constructLinkedList([1,1,1,2,3])).toString()).toEqual('2, 3') + expect(deleteDuplicates(constructLinkedList([1, 1, 1, 2, 3])).toString()).toEqual('2, 3') }) diff --git a/src/test/ts/g0001_0100/s0086_partition_list/solution.test.ts b/src/test/ts/g0001_0100/s0086_partition_list/solution.test.ts index f7f4d40..2e2f174 100644 --- a/src/test/ts/g0001_0100/s0086_partition_list/solution.test.ts +++ b/src/test/ts/g0001_0100/s0086_partition_list/solution.test.ts @@ -4,9 +4,9 @@ import { expect, test } from 'vitest' import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils' test('partition', () => { - expect(partition(constructLinkedList([1,4,3,2,5,2]), 3).toString()).toEqual('1, 2, 2, 4, 3, 5') + expect(partition(constructLinkedList([1, 4, 3, 2, 5, 2]), 3).toString()).toEqual('1, 2, 2, 4, 3, 5') }) test('partition2', () => { - expect(partition(constructLinkedList([2,1]), 2).toString()).toEqual('1, 2') + expect(partition(constructLinkedList([2, 1]), 2).toString()).toEqual('1, 2') }) diff --git a/src/test/ts/g0001_0100/s0088_merge_sorted_array/solution.test.ts b/src/test/ts/g0001_0100/s0088_merge_sorted_array/solution.test.ts index 66d8ea3..b1bfd97 100644 --- a/src/test/ts/g0001_0100/s0088_merge_sorted_array/solution.test.ts +++ b/src/test/ts/g0001_0100/s0088_merge_sorted_array/solution.test.ts @@ -3,9 +3,9 @@ import { merge } from 'src/main/ts/g0001_0100/s0088_merge_sorted_array/solution' import { expect, test } from 'vitest' test('merge', () => { - const nums1 = [1,2,3,0,0,0] - merge(nums1, 3, [2,5,6], 3) - expect(nums1).toEqual([1,2,2,3,5,6]) + const nums1 = [1, 2, 3, 0, 0, 0] + merge(nums1, 3, [2, 5, 6], 3) + expect(nums1).toEqual([1, 2, 2, 3, 5, 6]) }) test('merge2', () => { diff --git a/src/test/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.test.ts b/src/test/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.test.ts index 8888d00..6377584 100644 --- a/src/test/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.test.ts +++ b/src/test/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.test.ts @@ -4,7 +4,7 @@ import { expect, test } from 'vitest' import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils' test('reverseBetween', () => { - expect(reverseBetween(constructLinkedList([1,2,3,4,5]), 2, 4).toString()).toEqual('1, 4, 3, 2, 5') + expect(reverseBetween(constructLinkedList([1, 2, 3, 4, 5]), 2, 4).toString()).toEqual('1, 4, 3, 2, 5') }) test('reverseBetween2', () => { From 9be06a9b8610f7d89a1ee0ac3d2549a9382663a2 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Mon, 7 Apr 2025 13:21:31 +0700 Subject: [PATCH 27/49] Added tasks 97-112 --- README.md | 16 ++++++ .../s0097_interleaving_string/readme.md | 42 +++++++++++++++ .../s0097_interleaving_string/solution.ts | 38 +++++++++++++ .../readme.md | 30 +++++++++++ .../solution.ts | 54 +++++++++++++++++++ .../readme.md | 29 ++++++++++ .../solution.ts | 36 +++++++++++++ .../readme.md | 33 ++++++++++++ .../solution.ts | 35 ++++++++++++ .../ts/g0101_0200/s0112_path_sum/readme.md | 36 +++++++++++++ .../ts/g0101_0200/s0112_path_sum/solution.ts | 29 ++++++++++ .../solution.test.ts | 11 ++++ .../solution.test.ts | 16 ++++++ .../solution.test.ts | 12 +++++ .../solution.test.ts | 12 +++++ .../s0112_path_sum/solution.test.ts | 16 ++++++ 16 files changed, 445 insertions(+) create mode 100644 src/main/ts/g0001_0100/s0097_interleaving_string/readme.md create mode 100644 src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts create mode 100644 src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/readme.md create mode 100644 src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts create mode 100644 src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/readme.md create mode 100644 src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts create mode 100644 src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/readme.md create mode 100644 src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts create mode 100644 src/main/ts/g0101_0200/s0112_path_sum/readme.md create mode 100644 src/main/ts/g0101_0200/s0112_path_sum/solution.ts create mode 100644 src/test/ts/g0001_0100/s0097_interleaving_string/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0112_path_sum/solution.test.ts diff --git a/README.md b/README.md index c7eb371..5ebd503 100644 --- a/README.md +++ b/README.md @@ -776,6 +776,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 | 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 10 Graph/BFS/DFS @@ -945,6 +946,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 | 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 1 | 87.16 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 @@ -1096,7 +1099,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 +| 0106 |[Construct Binary Tree from Inorder and Postorder Traversal](src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts)| Medium | Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer | 1 | 98.78 | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0112 |[Path Sum](src/main/ts/g0101_0200/s0112_path_sum/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 @@ -1105,6 +1110,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 #### Top Interview 150 Binary Search Tree @@ -1147,6 +1153,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 | 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 36 | 44.94 | 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 4 | 97.65 @@ -1207,6 +1214,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0063 |[Unique Paths II](src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 +| 0097 |[Interleaving String](src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts)| Medium | String, Dynamic_Programming | 43 | 97.65 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 @@ -1286,6 +1294,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0112 |[Path Sum](src/main/ts/g0101_0200/s0112_path_sum/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 #### Day 13 Tree @@ -1393,7 +1402,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 +| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 #### Day 16 Tree @@ -1697,11 +1708,16 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Data_Structure_I_Day_3_Array, Dynamic_Programming_I_Day_7, Level_1_Day_5_Greedy, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Udemy_Linked_List, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0112 |[Path Sum](src/main/ts/g0101_0200/s0112_path_sum/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Top_Interview_150_Binary_Tree_General | 0 | 100.00 +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Level_2_Day_9_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Divide_and_Conquer | 0 | 100.00 +| 0106 |[Construct Binary Tree from Inorder and Postorder Traversal](src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts)| Medium | Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Top_Interview_150_Binary_Tree_General | 1 | 98.78 | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Programming_Skills_I_Day_10_Linked_List_and_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_15_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS | 0 | 100.00 | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_1_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_I_Day_14_Tree, Level_1_Day_8_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0097 |[Interleaving String](src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts)| Medium | String, Dynamic_Programming, Top_Interview_150_Multidimensional_DP | 43 | 97.65 | 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Dynamic_Programming_I_Day_11, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Data_Structure_I_Day_10_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0092 |[Reverse Linked List II](src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.ts)| Medium | Linked_List, Top_Interview_150_Linked_List | 0 | 100.00 diff --git a/src/main/ts/g0001_0100/s0097_interleaving_string/readme.md b/src/main/ts/g0001_0100/s0097_interleaving_string/readme.md new file mode 100644 index 0000000..3ad6417 --- /dev/null +++ b/src/main/ts/g0001_0100/s0097_interleaving_string/readme.md @@ -0,0 +1,42 @@ +97\. Interleaving String + +Medium + +Given strings `s1`, `s2`, and `s3`, find whether `s3` is formed by an **interleaving** of `s1` and `s2`. + +An **interleaving** of two strings `s` and `t` is a configuration where they are divided into **non-empty** substrings such that: + +* s = s1 + s2 + ... + sn +* t = t1 + t2 + ... + tm +* `|n - m| <= 1` +* The **interleaving** is s1 + t1 + s2 + t2 + s3 + t3 + ... or t1 + s1 + t2 + s2 + t3 + s3 + ... + +**Note:** `a + b` is the concatenation of strings `a` and `b`. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/09/02/interleave.jpg) + +**Input:** s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac" + +**Output:** true + +**Example 2:** + +**Input:** s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc" + +**Output:** false + +**Example 3:** + +**Input:** s1 = "", s2 = "", s3 = "" + +**Output:** true + +**Constraints:** + +* `0 <= s1.length, s2.length <= 100` +* `0 <= s3.length <= 200` +* `s1`, `s2`, and `s3` consist of lowercase English letters. + +**Follow up:** Could you solve it using only `O(s2.length)` additional memory space? diff --git a/src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts b/src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts new file mode 100644 index 0000000..4823a72 --- /dev/null +++ b/src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts @@ -0,0 +1,38 @@ +// #Medium #String #Dynamic_Programming #Top_Interview_150_Multidimensional_DP +// #2025_04_05_Time_43_ms_(97.65%)_Space_58.17_MB_(61.77%) + +function isInterleave(s1: string, s2: string, s3: string): boolean { + if (s3.length !== (s1.length + s2.length)) { + return false + } + const cache: boolean[][] = Array.from({ length: s1.length + 1 }, () => Array(s2.length + 1).fill(null)) + return isInterleaveHelper(s1, s2, s3, 0, 0, 0, cache) +} + +function isInterleaveHelper( + s1: string, + s2: string, + s3: string, + i1: number, + i2: number, + i3: number, + cache: boolean[][] +): boolean { + if (cache[i1][i2] !== null) { + return cache[i1][i2] + } + if (i1 === s1.length && i2 === s2.length && i3 === s3.length) { + return true + } + let result = false + if (i1 < s1.length && s1.charAt(i1) === s3.charAt(i3)) { + result = isInterleaveHelper(s1, s2, s3, i1 + 1, i2, i3 + 1, cache) + } + if (i2 < s2.length && s2.charAt(i2) === s3.charAt(i3)) { + result = result || isInterleaveHelper(s1, s2, s3, i1, i2 + 1, i3 + 1, cache) + } + cache[i1][i2] = result + return result +} + +export { isInterleave } diff --git a/src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/readme.md b/src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/readme.md new file mode 100644 index 0000000..d403d28 --- /dev/null +++ b/src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/readme.md @@ -0,0 +1,30 @@ +103\. Binary Tree Zigzag Level Order Traversal + +Medium + +Given the `root` of a binary tree, return _the zigzag level order traversal of its nodes' values_. (i.e., from left to right, then right to left for the next level and alternate between). + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg) + +**Input:** root = [3,9,20,null,null,15,7] + +**Output:** [[3],[20,9],[15,7]] + +**Example 2:** + +**Input:** root = [1] + +**Output:** [[1]] + +**Example 3:** + +**Input:** root = [] + +**Output:** [] + +**Constraints:** + +* The number of nodes in the tree is in the range `[0, 2000]`. +* `-100 <= Node.val <= 100` diff --git a/src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts b/src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts new file mode 100644 index 0000000..5f57a79 --- /dev/null +++ b/src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts @@ -0,0 +1,54 @@ +// #Medium #Top_Interview_Questions #Breadth_First_Search #Tree #Binary_Tree +// #Data_Structure_II_Day_15_Tree #Udemy_Tree_Stack_Queue #Top_Interview_150_Binary_Tree_BFS +// #2025_04_05_Time_0_ms_(100.00%)_Space_58.00_MB_(52.61%) + +import { TreeNode } from '../../com_github_leetcode/treenode' + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +function zigzagLevelOrder(root: TreeNode | null): number[][] { + const result: number[][] = [] + if (root === null) { + return result + } + const q: (TreeNode | null)[] = [root, null] + let zig = true + let level: number[] = [] + while (q.length > 0) { + const node = q.shift() + if (node === null) { + result.push(level) + zig = !zig + level = [] + if (q.length > 0) { + q.push(null) + } + } else { + if (zig) { + level.push(node.val) + } else { + level.unshift(node.val) + } + if (node.left !== null) { + q.push(node.left) + } + if (node.right !== null) { + q.push(node.right) + } + } + } + return result +} + +export { zigzagLevelOrder } diff --git a/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/readme.md b/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/readme.md new file mode 100644 index 0000000..65ba6b3 --- /dev/null +++ b/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/readme.md @@ -0,0 +1,29 @@ +106\. Construct Binary Tree from Inorder and Postorder Traversal + +Medium + +Given two integer arrays `inorder` and `postorder` where `inorder` is the inorder traversal of a binary tree and `postorder` is the postorder traversal of the same tree, construct and return _the binary tree_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/02/19/tree.jpg) + +**Input:** inorder = [9,3,15,20,7], postorder = [9,15,7,20,3] + +**Output:** [3,9,20,null,null,15,7] + +**Example 2:** + +**Input:** inorder = [-1], postorder = [-1] + +**Output:** [-1] + +**Constraints:** + +* `1 <= inorder.length <= 3000` +* `postorder.length == inorder.length` +* `-3000 <= inorder[i], postorder[i] <= 3000` +* `inorder` and `postorder` consist of **unique** values. +* Each value of `postorder` also appears in `inorder`. +* `inorder` is **guaranteed** to be the inorder traversal of the tree. +* `postorder` is **guaranteed** to be the postorder traversal of the tree. diff --git a/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts b/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts new file mode 100644 index 0000000..5b4a677 --- /dev/null +++ b/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts @@ -0,0 +1,36 @@ +// #Medium #Array #Hash_Table #Tree #Binary_Tree #Divide_and_Conquer +// #Top_Interview_150_Binary_Tree_General #2025_04_05_Time_1_ms_(98.78%)_Space_59.57_MB_(88.16%) + +import { TreeNode } from '../../com_github_leetcode/treenode' + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +function buildTree(inorder: number[], postorder: number[]): TreeNode | null { + const inIndex: number[] = [inorder.length - 1] + const postIndex: number[] = [postorder.length - 1] + return helper(inorder, postorder, inIndex, postIndex, Number.MAX_VALUE) +} + +function helper(inorder: number[], postorder: number[], inIndex: number[], postIndex: number[], target: number): TreeNode | null { + if (inIndex[0] < 0 || inorder[inIndex[0]] === target) { + return null + } + const root = new TreeNode(postorder[postIndex[0]--]) + root.right = helper(inorder, postorder, inIndex, postIndex, root.val) + inIndex[0]-- + root.left = helper(inorder, postorder, inIndex, postIndex, target) + return root +} + +export { buildTree } diff --git a/src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/readme.md b/src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/readme.md new file mode 100644 index 0000000..09b5c6e --- /dev/null +++ b/src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/readme.md @@ -0,0 +1,33 @@ +108\. Convert Sorted Array to Binary Search Tree + +Easy + +Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a **height-balanced** binary search tree_. + +A **height-balanced** binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/02/18/btree1.jpg) + +**Input:** nums = [-10,-3,0,5,9] + +**Output:** [0,-3,9,-10,null,5] + +**Explanation:** [0,-10,5,null,-3,null,9] is also accepted: ![](https://assets.leetcode.com/uploads/2021/02/18/btree2.jpg) + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2021/02/18/btree.jpg) + +**Input:** nums = [1,3] + +**Output:** [3,1] + +**Explanation:** [1,3] and [3,1] are both a height-balanced BSTs. + +**Constraints:** + +* 1 <= nums.length <= 104 +* -104 <= nums[i] <= 104 +* `nums` is sorted in a **strictly increasing** order. diff --git a/src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts b/src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts new file mode 100644 index 0000000..05dcdea --- /dev/null +++ b/src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts @@ -0,0 +1,35 @@ +// #Easy #Top_Interview_Questions #Array #Tree #Binary_Tree #Binary_Search_Tree #Divide_and_Conquer +// #Data_Structure_II_Day_15_Tree #Level_2_Day_9_Binary_Search_Tree #Udemy_Tree_Stack_Queue +// #Top_Interview_150_Divide_and_Conquer #2025_04_05_Time_0_ms_(100.00%)_Space_59.64_MB_(37.39%) + +import { TreeNode } from '../../com_github_leetcode/treenode' + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +function sortedArrayToBST(nums: number[]): TreeNode | null { + return makeTree(nums, 0, nums.length - 1) +} + +function makeTree(nums: number[], left: number, right: number): TreeNode | null { + if (left > right) { + return null + } + const mid = Math.floor((left + right) / 2) + const midNode = new TreeNode(nums[mid]) + midNode.left = makeTree(nums, left, mid - 1) + midNode.right = makeTree(nums, mid + 1, right) + return midNode +} + +export { sortedArrayToBST } diff --git a/src/main/ts/g0101_0200/s0112_path_sum/readme.md b/src/main/ts/g0101_0200/s0112_path_sum/readme.md new file mode 100644 index 0000000..132f5d6 --- /dev/null +++ b/src/main/ts/g0101_0200/s0112_path_sum/readme.md @@ -0,0 +1,36 @@ +112\. Path Sum + +Easy + +Given the `root` of a binary tree and an integer `targetSum`, return `true` if the tree has a **root-to-leaf** path such that adding up all the values along the path equals `targetSum`. + +A **leaf** is a node with no children. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/01/18/pathsum1.jpg) + +**Input:** root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22 + +**Output:** true + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2021/01/18/pathsum2.jpg) + +**Input:** root = [1,2,3], targetSum = 5 + +**Output:** false + +**Example 3:** + +**Input:** root = [1,2], targetSum = 0 + +**Output:** false + +**Constraints:** + +* The number of nodes in the tree is in the range `[0, 5000]`. +* `-1000 <= Node.val <= 1000` +* `-1000 <= targetSum <= 1000` + \ No newline at end of file diff --git a/src/main/ts/g0101_0200/s0112_path_sum/solution.ts b/src/main/ts/g0101_0200/s0112_path_sum/solution.ts new file mode 100644 index 0000000..9a9f790 --- /dev/null +++ b/src/main/ts/g0101_0200/s0112_path_sum/solution.ts @@ -0,0 +1,29 @@ +// #Easy #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree #Data_Structure_I_Day_12_Tree +// #Top_Interview_150_Binary_Tree_General #2025_04_05_Time_0_ms_(100.00%)_Space_59.81_MB_(41.32%) + +import { TreeNode } from '../../com_github_leetcode/treenode' + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +function hasPathSum(root: TreeNode | null, targetSum: number): boolean { + if (root === null) { + return false + } + if (targetSum === root.val && root.left === null && root.right === null) { + return true + } + return hasPathSum(root.left, targetSum - root.val) || hasPathSum(root.right, targetSum - root.val) +} + +export { hasPathSum } diff --git a/src/test/ts/g0001_0100/s0097_interleaving_string/solution.test.ts b/src/test/ts/g0001_0100/s0097_interleaving_string/solution.test.ts new file mode 100644 index 0000000..8c6335f --- /dev/null +++ b/src/test/ts/g0001_0100/s0097_interleaving_string/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { isInterleave } from 'src/main/ts/g0001_0100/s0097_interleaving_string/solution' +import { expect, test } from 'vitest' + +test('isInterleave', () => { + expect(isInterleave('aabcc', 'dbbca', 'aadbbcbcac')).toEqual(true) +}) + +test('isInterleave2', () => { + expect(isInterleave('aabcc', 'dbbca', 'aadbbbaccc')).toEqual(false) +}) diff --git a/src/test/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.test.ts b/src/test/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.test.ts new file mode 100644 index 0000000..e20585b --- /dev/null +++ b/src/test/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.test.ts @@ -0,0 +1,16 @@ +// tslint:disable:no-magic-numbers +import { zigzagLevelOrder } from 'src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution' +import { expect, test } from 'vitest' +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' + +test('zigzagLevelOrder', () => { + expect(zigzagLevelOrder(createTreeNode([3, 9, 20, null, null, 15, 7]))).toEqual([[3],[20, 9],[15, 7]]) +}) + +test('zigzagLevelOrder2', () => { + expect(zigzagLevelOrder(createTreeNode([1]))).toEqual([[1]]) +}) + +test('zigzagLevelOrder3', () => { + expect(zigzagLevelOrder(createTreeNode([]))).toEqual([]) +}) diff --git a/src/test/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.test.ts b/src/test/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.test.ts new file mode 100644 index 0000000..8168042 --- /dev/null +++ b/src/test/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.test.ts @@ -0,0 +1,12 @@ +// tslint:disable:no-magic-numbers +import { buildTree } from 'src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution' +import { expect, test } from 'vitest' +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' + +test('buildTree', () => { + expect(buildTree([9, 3, 15, 20, 7], [9, 15, 7, 20, 3])).toEqual(createTreeNode([3, 9, 20, null, null, 15, 7])) +}) + +test('buildTree', () => { + expect(buildTree([-1], [-1])).toEqual(createTreeNode([-1])) +}) diff --git a/src/test/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.test.ts b/src/test/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.test.ts new file mode 100644 index 0000000..9ca1b18 --- /dev/null +++ b/src/test/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.test.ts @@ -0,0 +1,12 @@ +// tslint:disable:no-magic-numbers +import { sortedArrayToBST } from 'src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution' +import { expect, test } from 'vitest' +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' + +test('sortedArrayToBST', () => { + expect(sortedArrayToBST([-10, -3, 0, 5, 9])).toEqual(createTreeNode([0, -10, 5, null, -3, null, 9])) +}) + +test('sortedArrayToBST2', () => { + expect(sortedArrayToBST([1, 3])).toEqual(createTreeNode([1, null, 3])) +}) diff --git a/src/test/ts/g0101_0200/s0112_path_sum/solution.test.ts b/src/test/ts/g0101_0200/s0112_path_sum/solution.test.ts new file mode 100644 index 0000000..9f3a658 --- /dev/null +++ b/src/test/ts/g0101_0200/s0112_path_sum/solution.test.ts @@ -0,0 +1,16 @@ +// tslint:disable:no-magic-numbers +import { hasPathSum } from 'src/main/ts/g0101_0200/s0112_path_sum/solution' +import { expect, test } from 'vitest' +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' + +test('hasPathSum', () => { + expect(hasPathSum(createTreeNode([5, 4, 8, 11, null, 13, 4, 7, 2, null, null, null, 1]), 22)).toEqual(true) +}) + +test('hasPathSum2', () => { + expect(hasPathSum(createTreeNode([1, 2, 3]), 5)).toEqual(false) +}) + +test('hasPathSum3', () => { + expect(hasPathSum(createTreeNode([]), 0)).toEqual(false) +}) From c81ed06511aa03ebcea872f375f0efe7a4d5db61 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Mon, 7 Apr 2025 09:27:01 +0300 Subject: [PATCH 28/49] Improved tasks 97, 103, 106 --- .../ts/g0001_0100/s0097_interleaving_string/solution.ts | 4 ++-- .../solution.ts | 8 +++++++- .../solution.test.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts b/src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts index 4823a72..255f12f 100644 --- a/src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts +++ b/src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts @@ -2,7 +2,7 @@ // #2025_04_05_Time_43_ms_(97.65%)_Space_58.17_MB_(61.77%) function isInterleave(s1: string, s2: string, s3: string): boolean { - if (s3.length !== (s1.length + s2.length)) { + if (s3.length !== s1.length + s2.length) { return false } const cache: boolean[][] = Array.from({ length: s1.length + 1 }, () => Array(s2.length + 1).fill(null)) @@ -16,7 +16,7 @@ function isInterleaveHelper( i1: number, i2: number, i3: number, - cache: boolean[][] + cache: boolean[][], ): boolean { if (cache[i1][i2] !== null) { return cache[i1][i2] diff --git a/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts b/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts index 5b4a677..8188f36 100644 --- a/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts +++ b/src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts @@ -22,7 +22,13 @@ function buildTree(inorder: number[], postorder: number[]): TreeNode | null { return helper(inorder, postorder, inIndex, postIndex, Number.MAX_VALUE) } -function helper(inorder: number[], postorder: number[], inIndex: number[], postIndex: number[], target: number): TreeNode | null { +function helper( + inorder: number[], + postorder: number[], + inIndex: number[], + postIndex: number[], + target: number, +): TreeNode | null { if (inIndex[0] < 0 || inorder[inIndex[0]] === target) { return null } diff --git a/src/test/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.test.ts b/src/test/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.test.ts index e20585b..96bda40 100644 --- a/src/test/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.test.ts +++ b/src/test/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.test.ts @@ -4,7 +4,7 @@ import { expect, test } from 'vitest' import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' test('zigzagLevelOrder', () => { - expect(zigzagLevelOrder(createTreeNode([3, 9, 20, null, null, 15, 7]))).toEqual([[3],[20, 9],[15, 7]]) + expect(zigzagLevelOrder(createTreeNode([3, 9, 20, null, null, 15, 7]))).toEqual([[3], [20, 9], [15, 7]]) }) test('zigzagLevelOrder2', () => { From ea6647239ea378d9d9cd8387b833031814fea313 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Mon, 7 Apr 2025 16:53:30 +0700 Subject: [PATCH 29/49] Added tasks 117-125 --- README.md | 17 ++++++ src/main/ts/com_github_leetcode/_node.ts | 15 ++++++ .../readme.md | 37 +++++++++++++ .../solution.ts | 52 +++++++++++++++++++ .../ts/g0101_0200/s0120_triangle/readme.md | 37 +++++++++++++ .../ts/g0101_0200/s0120_triangle/solution.ts | 29 +++++++++++ .../readme.md | 38 ++++++++++++++ .../solution.ts | 15 ++++++ .../readme.md | 44 ++++++++++++++++ .../solution.ts | 18 +++++++ .../s0125_valid_palindrome/readme.md | 36 +++++++++++++ .../s0125_valid_palindrome/solution.ts | 14 +++++ .../solution.test.ts | 48 +++++++++++++++++ .../s0120_triangle/solution.test.ts | 11 ++++ .../solution.test.ts | 15 ++++++ .../solution.test.ts | 15 ++++++ .../s0125_valid_palindrome/solution.test.ts | 15 ++++++ 17 files changed, 456 insertions(+) create mode 100644 src/main/ts/com_github_leetcode/_node.ts create mode 100644 src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/readme.md create mode 100644 src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts create mode 100644 src/main/ts/g0101_0200/s0120_triangle/readme.md create mode 100644 src/main/ts/g0101_0200/s0120_triangle/solution.ts create mode 100644 src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/readme.md create mode 100644 src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts create mode 100644 src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/readme.md create mode 100644 src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts create mode 100644 src/main/ts/g0101_0200/s0125_valid_palindrome/readme.md create mode 100644 src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts create mode 100644 src/test/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0120_triangle/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0125_valid_palindrome/solution.test.ts diff --git a/README.md b/README.md index 5ebd503..ccf14fd 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 +| 0122 |[Best Time to Buy and Sell Stock II](src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 0 | 100.00 #### Day 8 @@ -277,6 +278,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0120 |[Triangle](src/main/ts/g0101_0200/s0120_triangle/solution.ts)| Medium | Array, Dynamic_Programming | 0 | 100.00 #### Day 14 @@ -884,6 +886,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String | 0 | 100.00 +| 0122 |[Best Time to Buy and Sell Stock II](src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 0 | 100.00 | 0080 |[Remove Duplicates from Sorted Array II](src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.ts)| Medium | Array, Two_Pointers | 40 | 99.63 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 @@ -897,6 +900,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0125 |[Valid Palindrome](src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers | 0 | 100.00 | 0026 |[Remove Duplicates from Sorted Array](src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 @@ -971,6 +975,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0120 |[Triangle](src/main/ts/g0101_0200/s0120_triangle/solution.ts)| Medium | Array, Dynamic_Programming | 0 | 100.00 | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 | 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 @@ -1016,6 +1021,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 +| 0122 |[Best Time to Buy and Sell Stock II](src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 0 | 100.00 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 @@ -1032,6 +1038,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0125 |[Valid Palindrome](src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers | 0 | 100.00 | 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 @@ -1100,6 +1107,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 | 0106 |[Construct Binary Tree from Inorder and Postorder Traversal](src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts)| Medium | Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer | 1 | 98.78 +| 0117 |[Populating Next Right Pointers in Each Node II](src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 47 | 97.74 | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0112 |[Path Sum](src/main/ts/g0101_0200/s0112_path_sum/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 @@ -1211,11 +1219,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0120 |[Triangle](src/main/ts/g0101_0200/s0120_triangle/solution.ts)| Medium | Array, Dynamic_Programming | 0 | 100.00 | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0063 |[Unique Paths II](src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 | 0097 |[Interleaving String](src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts)| Medium | String, Dynamic_Programming | 43 | 97.65 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 +| 0123 |[Best Time to Buy and Sell Stock III](src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts)| Hard | Array, Dynamic_Programming | 5 | 85.07 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 ### Data Structure I @@ -1512,6 +1522,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0120 |[Triangle](src/main/ts/g0101_0200/s0120_triangle/solution.ts)| Medium | Array, Dynamic_Programming | 0 | 100.00 #### Day 13 Bit Manipulation @@ -1569,6 +1580,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0117 |[Populating Next Right Pointers in Each Node II](src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 47 | 97.74 #### Day 8 Breadth First Search Depth First Search @@ -1705,8 +1717,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Data_Structure_II_Day_1_Array, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Integers, Top_Interview_150_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0131 |[Palindrome Partitioning](src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(N\*2^N)_Space_O(2^N\*N) | 13 | 94.96 | 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Top_Interview_150_Hashmap, Big_O_Time_O(N_log_N)_Space_O(1) | 34 | 90.07 +| 0125 |[Valid Palindrome](src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 +| 0123 |[Best Time to Buy and Sell Stock III](src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts)| Hard | Array, Dynamic_Programming, Top_Interview_150_Multidimensional_DP | 5 | 85.07 +| 0122 |[Best Time to Buy and Sell Stock II](src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Dynamic_Programming_I_Day_7, Udemy_Arrays, Top_Interview_150_Array/String | 0 | 100.00 | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Data_Structure_I_Day_3_Array, Dynamic_Programming_I_Day_7, Level_1_Day_5_Greedy, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 +| 0120 |[Triangle](src/main/ts/g0101_0200/s0120_triangle/solution.ts)| Medium | Array, Dynamic_Programming, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_13, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP | 0 | 100.00 +| 0117 |[Populating Next Right Pointers in Each Node II](src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List, Algorithm_II_Day_7_Breadth_First_Search_Depth_First_Search, Top_Interview_150_Binary_Tree_General | 47 | 97.74 | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Udemy_Linked_List, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0112 |[Path Sum](src/main/ts/g0101_0200/s0112_path_sum/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Top_Interview_150_Binary_Tree_General | 0 | 100.00 | 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Level_2_Day_9_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Divide_and_Conquer | 0 | 100.00 diff --git a/src/main/ts/com_github_leetcode/_node.ts b/src/main/ts/com_github_leetcode/_node.ts new file mode 100644 index 0000000..e3aa79d --- /dev/null +++ b/src/main/ts/com_github_leetcode/_node.ts @@ -0,0 +1,15 @@ +class _Node { + val: number + left: _Node | null + right: _Node | null + next: _Node | null + + constructor(val?: number, left?: _Node, right?: _Node, next?: _Node) { + this.val = val === undefined ? 0 : val + this.left = left === undefined ? null : left + this.right = right === undefined ? null : right + this.next = next === undefined ? null : next + } +} + +export { _Node } diff --git a/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/readme.md b/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/readme.md new file mode 100644 index 0000000..2d6ede4 --- /dev/null +++ b/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/readme.md @@ -0,0 +1,37 @@ +117\. Populating Next Right Pointers in Each Node II + +Medium + +Given a binary tree + +struct Node { int val; Node \*left; Node \*right; Node \*next; } + +Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to `NULL`. + +Initially, all next pointers are set to `NULL`. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2019/02/15/117_sample.png) + +**Input:** root = [1,2,3,4,5,null,7] + +**Output:** [1,#,2,3,#,4,5,7,#] + +**Explanation:** Given the above binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level. + +**Example 2:** + +**Input:** root = [] + +**Output:** [] + +**Constraints:** + +* The number of nodes in the tree is in the range `[0, 6000]`. +* `-100 <= Node.val <= 100` + +**Follow-up:** + +* You may only use constant extra space. +* The recursive approach is fine. You may assume implicit stack space does not count as extra space for this problem. diff --git a/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts b/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts new file mode 100644 index 0000000..76c10f4 --- /dev/null +++ b/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts @@ -0,0 +1,52 @@ +// #Medium #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree #Linked_List +// #Algorithm_II_Day_7_Breadth_First_Search_Depth_First_Search +// #Top_Interview_150_Binary_Tree_General #2025_04_07_Time_47_ms_(97.74%)_Space_61.19_MB_(53.38%) + +import { _Node } from "../../com_github_leetcode/_node" + +/** + * Definition for _Node. + * class _Node { + * val: number + * left: _Node | null + * right: _Node | null + * next: _Node | null + * + * constructor(val?: number, left?: _Node, right?: _Node, next?: _Node) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * this.next = (next===undefined ? null : next) + * } + * } + */ +function connect(root: _Node | null): _Node | null { + if (!root) { + return null + } + root.next = null + let dummyHead = new _Node() + let current: _Node | null = root + while (current) { + // reset dummyHead + dummyHead.next = null + let child = dummyHead + // traverse the current level + while (current) { + if (current.left) { + child.next = current.left + child = child.next + } + if (current.right) { + child.next = current.right + child = child.next + } + current = current.next + } + // move on to the next level + current = dummyHead.next + } + return root +} + +export { connect } diff --git a/src/main/ts/g0101_0200/s0120_triangle/readme.md b/src/main/ts/g0101_0200/s0120_triangle/readme.md new file mode 100644 index 0000000..6efc4a9 --- /dev/null +++ b/src/main/ts/g0101_0200/s0120_triangle/readme.md @@ -0,0 +1,37 @@ +120\. Triangle + +Medium + +Given a `triangle` array, return _the minimum path sum from top to bottom_. + +For each step, you may move to an adjacent number of the row below. More formally, if you are on index `i` on the current row, you may move to either index `i` or index `i + 1` on the next row. + +**Example 1:** + +**Input:** triangle = [[2],[3,4],[6,5,7],[4,1,8,3]] + +**Output:** 11 + +**Explanation:** + + The triangle looks like: + 2 + 3 4 + 6 5 7 + 4 1 8 3 + The minimum path sum from top to bottom is 2 + 3 + 5 + 1 = 11 (underlined above). + +**Example 2:** + +**Input:** triangle = [[-10]] + +**Output:** -10 + +**Constraints:** + +* `1 <= triangle.length <= 200` +* `triangle[0].length == 1` +* `triangle[i].length == triangle[i - 1].length + 1` +* -104 <= triangle[i][j] <= 104 + +**Follow up:** Could you do this using only `O(n)` extra space, where `n` is the total number of rows in the triangle? diff --git a/src/main/ts/g0101_0200/s0120_triangle/solution.ts b/src/main/ts/g0101_0200/s0120_triangle/solution.ts new file mode 100644 index 0000000..9c3f7bf --- /dev/null +++ b/src/main/ts/g0101_0200/s0120_triangle/solution.ts @@ -0,0 +1,29 @@ +// #Medium #Array #Dynamic_Programming #Algorithm_I_Day_12_Dynamic_Programming +// #Dynamic_Programming_I_Day_13 #Udemy_Dynamic_Programming #Top_Interview_150_Multidimensional_DP +// #2025_04_07_Time_0_ms_(100.00%)_Space_58.24_MB_(28.24%) + +function minimumTotal(triangle: number[][]): number { + if (!triangle || triangle.length === 0) { + return 0 + } + const rows = triangle.length + const cols = triangle[rows - 1].length + const dp: number[][] = Array.from({ length: rows }, () => Array(cols).fill(-10001)) + function dfs(row: number, col: number): number { + if (row >= triangle.length) { + return 0 + } + if (dp[row][col] !== -10001) { + return dp[row][col] + } + const sum = triangle[row][col] + Math.min( + dfs(row + 1, col), + dfs(row + 1, col + 1) + ) + dp[row][col] = sum + return sum + } + return dfs(0, 0) +} + +export { minimumTotal } diff --git a/src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/readme.md b/src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/readme.md new file mode 100644 index 0000000..bdb1456 --- /dev/null +++ b/src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/readme.md @@ -0,0 +1,38 @@ +122\. Best Time to Buy and Sell Stock II + +Medium + +You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day. + +On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**. + +Find and return _the **maximum** profit you can achieve_. + +**Example 1:** + +**Input:** prices = [7,1,5,3,6,4] + +**Output:** 7 + +**Explanation:** Buy on day 2 (price = 1) and sell on day 3 (price = 5), profit = 5-1 = 4. Then buy on day 4 (price = 3) and sell on day 5 (price = 6), profit = 6-3 = 3. Total profit is 4 + 3 = 7. + +**Example 2:** + +**Input:** prices = [1,2,3,4,5] + +**Output:** 4 + +**Explanation:** Buy on day 1 (price = 1) and sell on day 5 (price = 5), profit = 5-1 = 4. Total profit is 4. + +**Example 3:** + +**Input:** prices = [7,6,4,3,1] + +**Output:** 0 + +**Explanation:** There is no way to make a positive profit, so we never buy the stock to achieve the maximum profit of 0. + +**Constraints:** + +* 1 <= prices.length <= 3 * 104 +* 0 <= prices[i] <= 104 diff --git a/src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts b/src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts new file mode 100644 index 0000000..ba2d3e3 --- /dev/null +++ b/src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts @@ -0,0 +1,15 @@ +// #Medium #Top_Interview_Questions #Array #Dynamic_Programming #Greedy #Dynamic_Programming_I_Day_7 +// #Udemy_Arrays #Top_Interview_150_Array/String +// #2025_04_07_Time_0_ms_(100.00%)_Space_54.88_MB_(71.79%) + +function maxProfit(prices: number[]): number { + let max = 0 + for (let i = 1; i < prices.length; i++) { + if (prices[i] > prices[i - 1]) { + max += prices[i] - prices[i - 1] + } + } + return max +} + +export { maxProfit } diff --git a/src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/readme.md b/src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/readme.md new file mode 100644 index 0000000..05c8547 --- /dev/null +++ b/src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/readme.md @@ -0,0 +1,44 @@ +123\. Best Time to Buy and Sell Stock III + +Hard + +You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day. + +Find the maximum profit you can achieve. You may complete **at most two transactions**. + +**Note:** You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again). + +**Example 1:** + +**Input:** prices = [3,3,5,0,0,3,1,4] + +**Output:** 6 + +**Explanation:** Buy on day 4 (price = 0) and sell on day 6 (price = 3), profit = 3-0 = 3. Then buy on day 7 (price = 1) and sell on day 8 (price = 4), profit = 4-1 = 3. + +**Example 2:** + +**Input:** prices = [1,2,3,4,5] + +**Output:** 4 + +**Explanation:** Buy on day 1 (price = 1) and sell on day 5 (price = 5), profit = 5-1 = 4. Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are engaging multiple transactions at the same time. You must sell before buying again. + +**Example 3:** + +**Input:** prices = [7,6,4,3,1] + +**Output:** 0 + +**Explanation:** In this case, no transaction is done, i.e. max profit = 0. + +**Example 4:** + +**Input:** prices = [1] + +**Output:** 0 + +**Constraints:** + +* 1 <= prices.length <= 105 +* 0 <= prices[i] <= 105 diff --git a/src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts b/src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts new file mode 100644 index 0000000..a7a37ff --- /dev/null +++ b/src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts @@ -0,0 +1,18 @@ +// #Hard #Array #Dynamic_Programming #Top_Interview_150_Multidimensional_DP +// #2025_04_07_Time_5_ms_(85.07%)_Space_68.32_MB_(50.75%) + +function maxProfit(prices: number[]): number { + let firstBuy = Infinity + let secondBuy = Infinity + let firstSell = 0 + let secondSell = 0 + for (const price of prices) { + firstBuy = Math.min(firstBuy, price) + firstSell = Math.max(firstSell, price - firstBuy) + secondBuy = Math.min(secondBuy, price - firstSell) + secondSell = Math.max(secondSell, price - secondBuy) + } + return secondSell +} + +export { maxProfit } diff --git a/src/main/ts/g0101_0200/s0125_valid_palindrome/readme.md b/src/main/ts/g0101_0200/s0125_valid_palindrome/readme.md new file mode 100644 index 0000000..e522118 --- /dev/null +++ b/src/main/ts/g0101_0200/s0125_valid_palindrome/readme.md @@ -0,0 +1,36 @@ +125\. Valid Palindrome + +Easy + +A phrase is a **palindrome** if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. + +Given a string `s`, return `true` _if it is a **palindrome**, or_ `false` _otherwise_. + +**Example 1:** + +**Input:** s = "A man, a plan, a canal: Panama" + +**Output:** true + +**Explanation:** "amanaplanacanalpanama" is a palindrome. + +**Example 2:** + +**Input:** s = "race a car" + +**Output:** false + +**Explanation:** "raceacar" is not a palindrome. + +**Example 3:** + +**Input:** s = " " + +**Output:** true + +**Explanation:** s is an empty string "" after removing non-alphanumeric characters. Since an empty string reads the same forward and backward, it is a palindrome. + +**Constraints:** + +* 1 <= s.length <= 2 * 105 +* `s` consists only of printable ASCII characters. diff --git a/src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts b/src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts new file mode 100644 index 0000000..9adb7a5 --- /dev/null +++ b/src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts @@ -0,0 +1,14 @@ +// #Easy #Top_Interview_Questions #String #Two_Pointers #Udemy_Two_Pointers +// #Top_Interview_150_Two_Pointers #2025_04_07_Time_0_ms_(100.00%)_Space_59.34_MB_(42.47%) + +function isPalindrome(s: string): boolean { + if(s.length < 2) { + return true + } + let sFormated = s.toLowerCase().replace(/[^a-zA-Z0-9]/g, '') + let reversed = sFormated.split('').reverse().join('').replace(',','') + return sFormated === reversed + +} + +export { isPalindrome } diff --git a/src/test/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.test.ts b/src/test/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.test.ts new file mode 100644 index 0000000..22ccfac --- /dev/null +++ b/src/test/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.test.ts @@ -0,0 +1,48 @@ +// tslint:disable:no-magic-numbers +import { _Node } from 'src/main/ts/com_github_leetcode/_node'; +import { connect } from 'src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution' +import { expect, test } from 'vitest' + +test('connect', () => { + expect(connect(null)).toBeNull(); +}) + +test('connect2', () => { + const node = new _Node( + 1, + new _Node(2, new _Node(4), new _Node(5), null), + new _Node(3, null, new _Node(7), null), + null + ); + + const node7 = new _Node(7); + const node3 = new _Node(3, null, node7, null); + const node5 = new _Node(5, null, null, node7); + const node4 = new _Node(4, null, null, node5); + const node2 = new _Node(2, node4, node5, node3); + const node1 = new _Node(1, node2, node3, null); + + expect(connect(node)).toEqual(node1); +}) + +test('connect3', () => { + const node = new _Node( + 1, + new _Node(2, new _Node(4, new _Node(7), null, null), new _Node(5), null), + new _Node(3, null, new _Node(6, null, new _Node(8), null), null), + null + ); + + // Creating expected output tree with connections + const node8 = new _Node(8, null, null, null); + const node7 = new _Node(7, null, null, node8); + const node6 = new _Node(6, null, node8, null); + const node3 = new _Node(3, null, node6, null); + const node5 = new _Node(5, null, null, node6); + const node4 = new _Node(4, node7, null, node5); + const node2 = new _Node(2, node4, node5, node3); + const node1 = new _Node(1, node2, node3, null); + + // Connect nodes and compare + expect(connect(node)).toEqual(node1); +}) diff --git a/src/test/ts/g0101_0200/s0120_triangle/solution.test.ts b/src/test/ts/g0101_0200/s0120_triangle/solution.test.ts new file mode 100644 index 0000000..17881b4 --- /dev/null +++ b/src/test/ts/g0101_0200/s0120_triangle/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { minimumTotal } from 'src/main/ts/g0101_0200/s0120_triangle/solution' +import { expect, test } from 'vitest' + +test('minimumTotal', () => { + expect(minimumTotal([[2],[3,4],[6,5,7],[4,1,8,3]])).toEqual(11) +}) + +test('minimumTotal2', () => { + expect(minimumTotal([[-10]])).toEqual(-10) +}) diff --git a/src/test/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.test.ts b/src/test/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.test.ts new file mode 100644 index 0000000..7e2b6f2 --- /dev/null +++ b/src/test/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { maxProfit } from 'src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution' +import { expect, test } from 'vitest' + +test('maxProfit', () => { + expect(maxProfit([7,1,5,3,6,4])).toEqual(7) +}) + +test('maxProfit2', () => { + expect(maxProfit([1,2,3,4,5])).toEqual(4) +}) + +test('maxProfit3', () => { + expect(maxProfit([7,6,4,3,1])).toEqual(0) +}) diff --git a/src/test/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.test.ts b/src/test/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.test.ts new file mode 100644 index 0000000..6460fcc --- /dev/null +++ b/src/test/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { maxProfit } from 'src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution' +import { expect, test } from 'vitest' + +test('maxProfit', () => { + expect(maxProfit([3,3,5,0,0,3,1,4])).toEqual(6) +}) + +test('maxProfit2', () => { + expect(maxProfit([1,2,3,4,5])).toEqual(4) +}) + +test('maxProfit6', () => { + expect(maxProfit([7,6,4,3,1])).toEqual(0) +}) diff --git a/src/test/ts/g0101_0200/s0125_valid_palindrome/solution.test.ts b/src/test/ts/g0101_0200/s0125_valid_palindrome/solution.test.ts new file mode 100644 index 0000000..1b30a84 --- /dev/null +++ b/src/test/ts/g0101_0200/s0125_valid_palindrome/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { isPalindrome } from 'src/main/ts/g0101_0200/s0125_valid_palindrome/solution' +import { expect, test } from 'vitest' + +test('isPalindrome', () => { + expect(isPalindrome('A man, a plan, a canal: Panama')).toEqual(true) +}) + +test('isPalindrome2', () => { + expect(isPalindrome('race a car')).toEqual(false) +}) + +test('isPalindrome3', () => { + expect(isPalindrome(' ')).toEqual(true) +}) From f194b2dfde8a6940b538ba7c1275e3eaa219dd24 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Mon, 7 Apr 2025 13:03:15 +0300 Subject: [PATCH 30/49] Improved tasks 117-125 --- .../solution.ts | 4 +- .../ts/g0101_0200/s0120_triangle/solution.ts | 5 +- .../s0125_valid_palindrome/solution.ts | 5 +- .../solution.test.ts | 52 +++++++++---------- .../s0120_triangle/solution.test.ts | 2 +- .../solution.test.ts | 6 +-- .../solution.test.ts | 6 +-- 7 files changed, 38 insertions(+), 42 deletions(-) diff --git a/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts b/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts index 76c10f4..84ed1bd 100644 --- a/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts +++ b/src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts @@ -2,7 +2,7 @@ // #Algorithm_II_Day_7_Breadth_First_Search_Depth_First_Search // #Top_Interview_150_Binary_Tree_General #2025_04_07_Time_47_ms_(97.74%)_Space_61.19_MB_(53.38%) -import { _Node } from "../../com_github_leetcode/_node" +import { _Node } from '../../com_github_leetcode/_node' /** * Definition for _Node. @@ -11,7 +11,7 @@ import { _Node } from "../../com_github_leetcode/_node" * left: _Node | null * right: _Node | null * next: _Node | null - * + * * constructor(val?: number, left?: _Node, right?: _Node, next?: _Node) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ? null : left) diff --git a/src/main/ts/g0101_0200/s0120_triangle/solution.ts b/src/main/ts/g0101_0200/s0120_triangle/solution.ts index 9c3f7bf..d3e8a6d 100644 --- a/src/main/ts/g0101_0200/s0120_triangle/solution.ts +++ b/src/main/ts/g0101_0200/s0120_triangle/solution.ts @@ -16,10 +16,7 @@ function minimumTotal(triangle: number[][]): number { if (dp[row][col] !== -10001) { return dp[row][col] } - const sum = triangle[row][col] + Math.min( - dfs(row + 1, col), - dfs(row + 1, col + 1) - ) + const sum = triangle[row][col] + Math.min(dfs(row + 1, col), dfs(row + 1, col + 1)) dp[row][col] = sum return sum } diff --git a/src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts b/src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts index 9adb7a5..81df05d 100644 --- a/src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts +++ b/src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts @@ -2,13 +2,12 @@ // #Top_Interview_150_Two_Pointers #2025_04_07_Time_0_ms_(100.00%)_Space_59.34_MB_(42.47%) function isPalindrome(s: string): boolean { - if(s.length < 2) { + if (s.length < 2) { return true } let sFormated = s.toLowerCase().replace(/[^a-zA-Z0-9]/g, '') - let reversed = sFormated.split('').reverse().join('').replace(',','') + let reversed = sFormated.split('').reverse().join('').replace(',', '') return sFormated === reversed - } export { isPalindrome } diff --git a/src/test/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.test.ts b/src/test/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.test.ts index 22ccfac..57f4d23 100644 --- a/src/test/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.test.ts +++ b/src/test/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.test.ts @@ -1,10 +1,10 @@ // tslint:disable:no-magic-numbers -import { _Node } from 'src/main/ts/com_github_leetcode/_node'; +import { _Node } from 'src/main/ts/com_github_leetcode/_node' import { connect } from 'src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution' import { expect, test } from 'vitest' test('connect', () => { - expect(connect(null)).toBeNull(); + expect(connect(null)).toBeNull() }) test('connect2', () => { @@ -12,17 +12,17 @@ test('connect2', () => { 1, new _Node(2, new _Node(4), new _Node(5), null), new _Node(3, null, new _Node(7), null), - null - ); - - const node7 = new _Node(7); - const node3 = new _Node(3, null, node7, null); - const node5 = new _Node(5, null, null, node7); - const node4 = new _Node(4, null, null, node5); - const node2 = new _Node(2, node4, node5, node3); - const node1 = new _Node(1, node2, node3, null); - - expect(connect(node)).toEqual(node1); + null, + ) + + const node7 = new _Node(7) + const node3 = new _Node(3, null, node7, null) + const node5 = new _Node(5, null, null, node7) + const node4 = new _Node(4, null, null, node5) + const node2 = new _Node(2, node4, node5, node3) + const node1 = new _Node(1, node2, node3, null) + + expect(connect(node)).toEqual(node1) }) test('connect3', () => { @@ -30,19 +30,19 @@ test('connect3', () => { 1, new _Node(2, new _Node(4, new _Node(7), null, null), new _Node(5), null), new _Node(3, null, new _Node(6, null, new _Node(8), null), null), - null - ); - + null, + ) + // Creating expected output tree with connections - const node8 = new _Node(8, null, null, null); - const node7 = new _Node(7, null, null, node8); - const node6 = new _Node(6, null, node8, null); - const node3 = new _Node(3, null, node6, null); - const node5 = new _Node(5, null, null, node6); - const node4 = new _Node(4, node7, null, node5); - const node2 = new _Node(2, node4, node5, node3); - const node1 = new _Node(1, node2, node3, null); - + const node8 = new _Node(8, null, null, null) + const node7 = new _Node(7, null, null, node8) + const node6 = new _Node(6, null, node8, null) + const node3 = new _Node(3, null, node6, null) + const node5 = new _Node(5, null, null, node6) + const node4 = new _Node(4, node7, null, node5) + const node2 = new _Node(2, node4, node5, node3) + const node1 = new _Node(1, node2, node3, null) + // Connect nodes and compare - expect(connect(node)).toEqual(node1); + expect(connect(node)).toEqual(node1) }) diff --git a/src/test/ts/g0101_0200/s0120_triangle/solution.test.ts b/src/test/ts/g0101_0200/s0120_triangle/solution.test.ts index 17881b4..4404f47 100644 --- a/src/test/ts/g0101_0200/s0120_triangle/solution.test.ts +++ b/src/test/ts/g0101_0200/s0120_triangle/solution.test.ts @@ -3,7 +3,7 @@ import { minimumTotal } from 'src/main/ts/g0101_0200/s0120_triangle/solution' import { expect, test } from 'vitest' test('minimumTotal', () => { - expect(minimumTotal([[2],[3,4],[6,5,7],[4,1,8,3]])).toEqual(11) + expect(minimumTotal([[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]])).toEqual(11) }) test('minimumTotal2', () => { diff --git a/src/test/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.test.ts b/src/test/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.test.ts index 7e2b6f2..82d46de 100644 --- a/src/test/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.test.ts +++ b/src/test/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.test.ts @@ -3,13 +3,13 @@ import { maxProfit } from 'src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sel import { expect, test } from 'vitest' test('maxProfit', () => { - expect(maxProfit([7,1,5,3,6,4])).toEqual(7) + expect(maxProfit([7, 1, 5, 3, 6, 4])).toEqual(7) }) test('maxProfit2', () => { - expect(maxProfit([1,2,3,4,5])).toEqual(4) + expect(maxProfit([1, 2, 3, 4, 5])).toEqual(4) }) test('maxProfit3', () => { - expect(maxProfit([7,6,4,3,1])).toEqual(0) + expect(maxProfit([7, 6, 4, 3, 1])).toEqual(0) }) diff --git a/src/test/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.test.ts b/src/test/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.test.ts index 6460fcc..7c73ba3 100644 --- a/src/test/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.test.ts +++ b/src/test/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.test.ts @@ -3,13 +3,13 @@ import { maxProfit } from 'src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sel import { expect, test } from 'vitest' test('maxProfit', () => { - expect(maxProfit([3,3,5,0,0,3,1,4])).toEqual(6) + expect(maxProfit([3, 3, 5, 0, 0, 3, 1, 4])).toEqual(6) }) test('maxProfit2', () => { - expect(maxProfit([1,2,3,4,5])).toEqual(4) + expect(maxProfit([1, 2, 3, 4, 5])).toEqual(4) }) test('maxProfit6', () => { - expect(maxProfit([7,6,4,3,1])).toEqual(0) + expect(maxProfit([7, 6, 4, 3, 1])).toEqual(0) }) From ef6fb5bcffc1f3ecabd32bbef26d82029047cf99 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Mon, 7 Apr 2025 22:33:50 +0700 Subject: [PATCH 31/49] Added tasks 127-137 --- README.md | 11 +++++ .../ts/g0101_0200/s0127_word_ladder/readme.md | 37 +++++++++++++++ .../g0101_0200/s0127_word_ladder/solution.ts | 44 +++++++++++++++++ .../s0129_sum_root_to_leaf_numbers/readme.md | 39 +++++++++++++++ .../solution.ts | 41 ++++++++++++++++ .../ts/g0101_0200/s0134_gas_station/readme.md | 47 +++++++++++++++++++ .../g0101_0200/s0134_gas_station/solution.ts | 20 ++++++++ src/main/ts/g0101_0200/s0135_candy/readme.md | 34 ++++++++++++++ .../ts/g0101_0200/s0135_candy/solution.ts | 20 ++++++++ .../s0137_single_number_ii/readme.md | 25 ++++++++++ .../s0137_single_number_ii/solution.ts | 14 ++++++ .../s0127_word_ladder/solution.test.ts | 11 +++++ .../solution.test.ts | 12 +++++ .../s0134_gas_station/solution.test.ts | 11 +++++ .../g0101_0200/s0135_candy/solution.test.ts | 11 +++++ .../s0137_single_number_ii/solution.test.ts | 11 +++++ 16 files changed, 388 insertions(+) create mode 100644 src/main/ts/g0101_0200/s0127_word_ladder/readme.md create mode 100644 src/main/ts/g0101_0200/s0127_word_ladder/solution.ts create mode 100644 src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/readme.md create mode 100644 src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts create mode 100644 src/main/ts/g0101_0200/s0134_gas_station/readme.md create mode 100644 src/main/ts/g0101_0200/s0134_gas_station/solution.ts create mode 100644 src/main/ts/g0101_0200/s0135_candy/readme.md create mode 100644 src/main/ts/g0101_0200/s0135_candy/solution.ts create mode 100644 src/main/ts/g0101_0200/s0137_single_number_ii/readme.md create mode 100644 src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts create mode 100644 src/test/ts/g0101_0200/s0127_word_ladder/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0134_gas_station/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0135_candy/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0137_single_number_ii/solution.test.ts diff --git a/README.md b/README.md index ccf14fd..4ba55e8 100644 --- a/README.md +++ b/README.md @@ -570,6 +570,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0127 |[Word Ladder](src/main/ts/g0101_0200/s0127_word_ladder/solution.ts)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 41 | 95.63 #### Day 13 Graph Theory @@ -1025,6 +1026,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 +| 0134 |[Gas Station](src/main/ts/g0101_0200/s0134_gas_station/solution.ts)| Medium | Top_Interview_Questions, Array, Greedy | 0 | 100.00 +| 0135 |[Candy](src/main/ts/g0101_0200/s0135_candy/solution.ts)| Hard | Array, Greedy | 2 | 96.15 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0013 |[Roman to Integer](src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Math | 3 | 94.58 | 0012 |[Integer to Roman](src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts)| Medium | String, Hash_Table, Math | 3 | 93.02 @@ -1110,6 +1113,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0117 |[Populating Next Right Pointers in Each Node II](src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 47 | 97.74 | 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0112 |[Path Sum](src/main/ts/g0101_0200/s0112_path_sum/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0129 |[Sum Root to Leaf Numbers](src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 @@ -1138,6 +1142,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0127 |[Word Ladder](src/main/ts/g0101_0200/s0127_word_ladder/solution.ts)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 41 | 95.63 #### Top Interview 150 Trie @@ -1195,6 +1200,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0067 |[Add Binary](src/main/ts/g0001_0100/s0067_add_binary/solution.ts)| Easy | String, Math, Bit_Manipulation, Simulation | 0 | 100.00 | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +| 0137 |[Single Number II](src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts)| Medium | Array, Bit_Manipulation | 0 | 100.00 #### Top Interview 150 Math @@ -1714,9 +1720,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_I_Day_7_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(N)_Space_O(1) | 47 | 89.37 | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Algorithm_II_Day_15_Dynamic_Programming, Dynamic_Programming_I_Day_9, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 | 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Programming_Skills_II_Day_14, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(N)_Space_O(N) | 49 | 72.42 +| 0137 |[Single Number II](src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts)| Medium | Array, Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 0 | 100.00 | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Data_Structure_II_Day_1_Array, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Integers, Top_Interview_150_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +| 0135 |[Candy](src/main/ts/g0101_0200/s0135_candy/solution.ts)| Hard | Array, Greedy, Top_Interview_150_Array/String | 2 | 96.15 +| 0134 |[Gas Station](src/main/ts/g0101_0200/s0134_gas_station/solution.ts)| Medium | Top_Interview_Questions, Array, Greedy, Top_Interview_150_Array/String | 0 | 100.00 | 0131 |[Palindrome Partitioning](src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(N\*2^N)_Space_O(2^N\*N) | 13 | 94.96 +| 0129 |[Sum Root to Leaf Numbers](src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Top_Interview_150_Binary_Tree_General | 0 | 100.00 | 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Top_Interview_150_Hashmap, Big_O_Time_O(N_log_N)_Space_O(1) | 34 | 90.07 +| 0127 |[Word Ladder](src/main/ts/g0101_0200/s0127_word_ladder/solution.ts)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search, Graph_Theory_I_Day_12_Breadth_First_Search, Top_Interview_150_Graph_BFS | 41 | 95.63 | 0125 |[Valid Palindrome](src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0123 |[Best Time to Buy and Sell Stock III](src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts)| Hard | Array, Dynamic_Programming, Top_Interview_150_Multidimensional_DP | 5 | 85.07 diff --git a/src/main/ts/g0101_0200/s0127_word_ladder/readme.md b/src/main/ts/g0101_0200/s0127_word_ladder/readme.md new file mode 100644 index 0000000..1d78d22 --- /dev/null +++ b/src/main/ts/g0101_0200/s0127_word_ladder/readme.md @@ -0,0 +1,37 @@ +127\. Word Ladder + +Hard + +A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: + +* Every adjacent pair of words differs by a single letter. +* Every si for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need to be in `wordList`. +* sk == endWord + +Given two words, `beginWord` and `endWord`, and a dictionary `wordList`, return _the **number of words** in the **shortest transformation sequence** from_ `beginWord` _to_ `endWord`_, or_ `0` _if no such sequence exists._ + +**Example 1:** + +**Input:** beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"] + +**Output:** 5 + +**Explanation:** One shortest transformation sequence is "hit" -> "hot" -> "dot" -> "dog" -> cog", which is 5 words long. + +**Example 2:** + +**Input:** beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"] + +**Output:** 0 + +**Explanation:** The endWord "cog" is not in wordList, therefore there is no valid transformation sequence. + +**Constraints:** + +* `1 <= beginWord.length <= 10` +* `endWord.length == beginWord.length` +* `1 <= wordList.length <= 5000` +* `wordList[i].length == beginWord.length` +* `beginWord`, `endWord`, and `wordList[i]` consist of lowercase English letters. +* `beginWord != endWord` +* All the words in `wordList` are **unique**. diff --git a/src/main/ts/g0101_0200/s0127_word_ladder/solution.ts b/src/main/ts/g0101_0200/s0127_word_ladder/solution.ts new file mode 100644 index 0000000..0cc5c05 --- /dev/null +++ b/src/main/ts/g0101_0200/s0127_word_ladder/solution.ts @@ -0,0 +1,44 @@ +// #Hard #Top_Interview_Questions #String #Hash_Table #Breadth_First_Search +// #Graph_Theory_I_Day_12_Breadth_First_Search #Top_Interview_150_Graph_BFS +// #2025_04_07_Time_41_ms_(95.63%)_Space_63.50_MB_(82.78%) + +function ladderLength(beginWord: string, endWord: string, wordList: string[]): number { + const wordSet: Set = new Set(wordList) + if (!wordSet.has(endWord)) { + return 0 + } + let beginSet: Set = new Set([beginWord]) + let endSet: Set = new Set([endWord]) + const visited: Set = new Set() + let len = 1 + const wordLen = beginWord.length + while (beginSet.size > 0 && endSet.size > 0) { + if (beginSet.size > endSet.size) { + [beginSet, endSet] = [endSet, beginSet] + } + const tempSet: Set = new Set() + for (const word of beginSet) { + const chars = word.split('') + for (let i = 0; i < wordLen; i++) { + const oldChar = chars[i] + for (let c = 97; c <= 122; c++) { + chars[i] = String.fromCharCode(c) + const nextWord = chars.join('') + if (endSet.has(nextWord)) { + return len + 1 + } + if (!visited.has(nextWord) && wordSet.has(nextWord)) { + tempSet.add(nextWord) + visited.add(nextWord) + } + } + chars[i] = oldChar + } + } + beginSet = tempSet + len++ + } + return 0 +} + +export { ladderLength } diff --git a/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/readme.md b/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/readme.md new file mode 100644 index 0000000..c9d9fca --- /dev/null +++ b/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/readme.md @@ -0,0 +1,39 @@ +129\. Sum Root to Leaf Numbers + +Medium + +You are given the `root` of a binary tree containing digits from `0` to `9` only. + +Each root-to-leaf path in the tree represents a number. + +* For example, the root-to-leaf path `1 -> 2 -> 3` represents the number `123`. + +Return _the total sum of all root-to-leaf numbers_. Test cases are generated so that the answer will fit in a **32-bit** integer. + +A **leaf** node is a node with no children. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/02/19/num1tree.jpg) + +**Input:** root = [1,2,3] + +**Output:** 25 + +**Explanation:** The root-to-leaf path `1->2` represents the number `12`. The root-to-leaf path `1->3` represents the number `13`. Therefore, sum = 12 + 13 = `25`. + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2021/02/19/num2tree.jpg) + +**Input:** root = [4,9,0,5,1] + +**Output:** 1026 + +**Explanation:** The root-to-leaf path `4->9->5` represents the number 495. The root-to-leaf path `4->9->1` represents the number 491. The root-to-leaf path `4->0` represents the number 40. Therefore, sum = 495 + 491 + 40 = `1026`. + +**Constraints:** + +* The number of nodes in the tree is in the range `[1, 1000]`. +* `0 <= Node.val <= 9` +* The depth of the tree will not exceed `10`. diff --git a/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts b/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts new file mode 100644 index 0000000..3874716 --- /dev/null +++ b/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts @@ -0,0 +1,41 @@ +// #Medium #Depth_First_Search #Tree #Binary_Tree #Top_Interview_150_Binary_Tree_General +// #2025_04_07_Time_0_ms_(100.00%)_Space_57.72_MB_(19.07%) + +import { TreeNode } from "../../com_github_leetcode/treenode" + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +function sumNumbers(root: TreeNode | null): number { + let sum = 0 + function recurseSum(node: TreeNode | null, curNum: number): void { + if (node === null) { + return + } + const newNum = 10 * curNum + node.val + if (node.left === null && node.right === null) { + sum += newNum + return + } + if (node.left !== null) { + recurseSum(node.left, newNum) + } + if (node.right !== null) { + recurseSum(node.right, newNum) + } + } + recurseSum(root, 0) + return sum +} + +export { sumNumbers } diff --git a/src/main/ts/g0101_0200/s0134_gas_station/readme.md b/src/main/ts/g0101_0200/s0134_gas_station/readme.md new file mode 100644 index 0000000..30790f3 --- /dev/null +++ b/src/main/ts/g0101_0200/s0134_gas_station/readme.md @@ -0,0 +1,47 @@ +134\. Gas Station + +Medium + +There are `n` gas stations along a circular route, where the amount of gas at the ith station is `gas[i]`. + +You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the ith station to its next (i + 1)th station. You begin the journey with an empty tank at one of the gas stations. + +Given two integer arrays `gas` and `cost`, return _the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return_ `-1`. If there exists a solution, it is **guaranteed** to be **unique** + +**Example 1:** + +**Input:** gas = [1,2,3,4,5], cost = [3,4,5,1,2] + +**Output:** 3 + +**Explanation:** + + Start at station 3 (index 3) and fill up with 4 unit of gas. Your tank = 0 + 4 = 4 + Travel to station 4. Your tank = 4 - 1 + 5 = 8 + Travel to station 0. Your tank = 8 - 2 + 1 = 7 + Travel to station 1. Your tank = 7 - 3 + 2 = 6 + Travel to station 2. Your tank = 6 - 4 + 3 = 5 + Travel to station 3. The cost is 5. Your gas is just enough to travel back to station 3. + Therefore, return 3 as the starting index. + +**Example 2:** + +**Input:** gas = [2,3,4], cost = [3,4,3] + +**Output:** -1 + +**Explanation:** + + You can't start at station 0 or 1, as there is not enough gas to travel to the next station. + Let's start at station 2 and fill up with 4 unit of gas. Your tank = 0 + 4 = 4 + Travel to station 0. Your tank = 4 - 3 + 2 = 3 + Travel to station 1. Your tank = 3 - 3 + 3 = 3 + You cannot travel back to station 2, as it requires 4 unit of gas but you only have 3. + Therefore, you can't travel around the circuit once no matter where you start. + +**Constraints:** + +* `gas.length == n` +* `cost.length == n` +* 1 <= n <= 105 +* 0 <= gas[i], cost[i] <= 104 diff --git a/src/main/ts/g0101_0200/s0134_gas_station/solution.ts b/src/main/ts/g0101_0200/s0134_gas_station/solution.ts new file mode 100644 index 0000000..4706167 --- /dev/null +++ b/src/main/ts/g0101_0200/s0134_gas_station/solution.ts @@ -0,0 +1,20 @@ +// #Medium #Top_Interview_Questions #Array #Greedy #Top_Interview_150_Array/String +// #2025_04_07_Time_0_ms_(100.00%)_Space_66.31_MB_(63.11%) + +function canCompleteCircuit(gas: number[], cost: number[]): number { + let index = 0 + let total = 0 + let current = 0 + for (let i = 0; i < gas.length; i++) { + const balance = gas[i] - cost[i] + total += balance + current += balance + if (current < 0) { + index = i + 1 + current = 0 + } + } + return total >= 0 ? index : -1 +} + +export { canCompleteCircuit } diff --git a/src/main/ts/g0101_0200/s0135_candy/readme.md b/src/main/ts/g0101_0200/s0135_candy/readme.md new file mode 100644 index 0000000..f609f87 --- /dev/null +++ b/src/main/ts/g0101_0200/s0135_candy/readme.md @@ -0,0 +1,34 @@ +135\. Candy + +Hard + +There are `n` children standing in a line. Each child is assigned a rating value given in the integer array `ratings`. + +You are giving candies to these children subjected to the following requirements: + +* Each child must have at least one candy. +* Children with a higher rating get more candies than their neighbors. + +Return _the minimum number of candies you need to have to distribute the candies to the children_. + +**Example 1:** + +**Input:** ratings = [1,0,2] + +**Output:** 5 + +**Explanation:** You can allocate to the first, second and third child with 2, 1, 2 candies respectively. + +**Example 2:** + +**Input:** ratings = [1,2,2] + +**Output:** 4 + +**Explanation:** You can allocate to the first, second and third child with 1, 2, 1 candies respectively. The third child gets 1 candy because it satisfies the above two conditions. + +**Constraints:** + +* `n == ratings.length` +* 1 <= n <= 2 * 104 +* 0 <= ratings[i] <= 2 * 104 diff --git a/src/main/ts/g0101_0200/s0135_candy/solution.ts b/src/main/ts/g0101_0200/s0135_candy/solution.ts new file mode 100644 index 0000000..534522d --- /dev/null +++ b/src/main/ts/g0101_0200/s0135_candy/solution.ts @@ -0,0 +1,20 @@ +// #Hard #Array #Greedy #Top_Interview_150_Array/String +// #2025_04_07_Time_2_ms_(96.15%)_Space_61.00_MB_(33.47%) + +function candy(ratings: number[]): number { + const n = ratings.length + const candies: number[] = new Array(n).fill(1) + for (let i = 0; i < n - 1; i++) { + if (ratings[i + 1] > ratings[i]) { + candies[i + 1] = candies[i] + 1 + } + } + for (let i = n - 1; i > 0; i--) { + if (ratings[i - 1] > ratings[i] && candies[i - 1] < candies[i] + 1) { + candies[i - 1] = candies[i] + 1 + } + } + return candies.reduce((sum, c) => sum + c, 0) +} + +export { candy } diff --git a/src/main/ts/g0101_0200/s0137_single_number_ii/readme.md b/src/main/ts/g0101_0200/s0137_single_number_ii/readme.md new file mode 100644 index 0000000..91053fc --- /dev/null +++ b/src/main/ts/g0101_0200/s0137_single_number_ii/readme.md @@ -0,0 +1,25 @@ +137\. Single Number II + +Medium + +Given an integer array `nums` where every element appears **three times** except for one, which appears **exactly once**. _Find the single element and return it_. + +You must implement a solution with a linear runtime complexity and use only constant extra space. + +**Example 1:** + +**Input:** nums = [2,2,3,2] + +**Output:** 3 + +**Example 2:** + +**Input:** nums = [0,1,0,1,0,1,99] + +**Output:** 99 + +**Constraints:** + +* 1 <= nums.length <= 3 * 104 +* -231 <= nums[i] <= 231 - 1 +* Each element in `nums` appears exactly **three times** except for one element which appears **once**. diff --git a/src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts b/src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts new file mode 100644 index 0000000..653e9ec --- /dev/null +++ b/src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts @@ -0,0 +1,14 @@ +// #Medium #Array #Bit_Manipulation #Top_Interview_150_Bit_Manipulation +// #2025_04_07_Time_0_ms_(100.00%)_Space_59.11_MB_(24.16%) + +function singleNumber(nums: number[]): number { + let ones = 0 + let twos = 0 + for (const num of nums) { + ones = (ones ^ num) & (~twos) + twos = (twos ^ num) & (~ones) + } + return ones +} + +export { singleNumber } diff --git a/src/test/ts/g0101_0200/s0127_word_ladder/solution.test.ts b/src/test/ts/g0101_0200/s0127_word_ladder/solution.test.ts new file mode 100644 index 0000000..03d5d2c --- /dev/null +++ b/src/test/ts/g0101_0200/s0127_word_ladder/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { ladderLength } from 'src/main/ts/g0101_0200/s0127_word_ladder/solution' +import { expect, test } from 'vitest' + +test('ladderLength', () => { + expect(ladderLength('hit', 'cog', ['hot', 'dot', 'dog', 'lot', 'log', 'cog'])).toEqual(5) +}) + +test('ladderLength2', () => { + expect(ladderLength('hit', 'cog', ['hot', 'dot', 'dog', 'lot', 'log'])).toEqual(0) +}) diff --git a/src/test/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.test.ts b/src/test/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.test.ts new file mode 100644 index 0000000..1cae0eb --- /dev/null +++ b/src/test/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.test.ts @@ -0,0 +1,12 @@ +// tslint:disable:no-magic-numbers +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' +import { sumNumbers } from 'src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution' +import { expect, test } from 'vitest' + +test('sumNumbers', () => { + expect(sumNumbers(createTreeNode([1,2,3]))).toEqual(25) +}) + +test('sumNumbers2', () => { + expect(sumNumbers(createTreeNode([4,9,0,5,1]))).toEqual(1026) +}) diff --git a/src/test/ts/g0101_0200/s0134_gas_station/solution.test.ts b/src/test/ts/g0101_0200/s0134_gas_station/solution.test.ts new file mode 100644 index 0000000..d13aeea --- /dev/null +++ b/src/test/ts/g0101_0200/s0134_gas_station/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { canCompleteCircuit } from 'src/main/ts/g0101_0200/s0134_gas_station/solution' +import { expect, test } from 'vitest' + +test('canCompleteCircuit', () => { + expect(canCompleteCircuit([1, 2, 3, 4, 5], [3, 4, 5, 1, 2])).toEqual(3) +}) + +test('canCompleteCircuit2', () => { + expect(canCompleteCircuit([2, 3, 4], [3, 4, 3])).toEqual(-1) +}) diff --git a/src/test/ts/g0101_0200/s0135_candy/solution.test.ts b/src/test/ts/g0101_0200/s0135_candy/solution.test.ts new file mode 100644 index 0000000..92f5cde --- /dev/null +++ b/src/test/ts/g0101_0200/s0135_candy/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { candy } from 'src/main/ts/g0101_0200/s0135_candy/solution' +import { expect, test } from 'vitest' + +test('candy', () => { + expect(candy([1, 0, 2])).toEqual(5) +}) + +test('candy2', () => { + expect(candy([1, 2, 2])).toEqual(4) +}) diff --git a/src/test/ts/g0101_0200/s0137_single_number_ii/solution.test.ts b/src/test/ts/g0101_0200/s0137_single_number_ii/solution.test.ts new file mode 100644 index 0000000..dbb3717 --- /dev/null +++ b/src/test/ts/g0101_0200/s0137_single_number_ii/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { singleNumber } from 'src/main/ts/g0101_0200/s0137_single_number_ii/solution' +import { expect, test } from 'vitest' + +test('singleNumber', () => { + expect(singleNumber([2, 2, 3, 2])).toEqual(3) +}) + +test('singleNumber2', () => { + expect(singleNumber([0, 1, 0, 1, 0, 1, 99])).toEqual(99) +}) From d16e83435f5f0b338c9dd50024cb811575f12d88 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Mon, 7 Apr 2025 18:44:00 +0300 Subject: [PATCH 32/49] Improved tasks 127, 129, 137 --- src/main/ts/g0101_0200/s0127_word_ladder/solution.ts | 2 +- .../ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts | 2 +- src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts | 4 ++-- .../s0129_sum_root_to_leaf_numbers/solution.test.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/ts/g0101_0200/s0127_word_ladder/solution.ts b/src/main/ts/g0101_0200/s0127_word_ladder/solution.ts index 0cc5c05..521c4eb 100644 --- a/src/main/ts/g0101_0200/s0127_word_ladder/solution.ts +++ b/src/main/ts/g0101_0200/s0127_word_ladder/solution.ts @@ -14,7 +14,7 @@ function ladderLength(beginWord: string, endWord: string, wordList: string[]): n const wordLen = beginWord.length while (beginSet.size > 0 && endSet.size > 0) { if (beginSet.size > endSet.size) { - [beginSet, endSet] = [endSet, beginSet] + ;[beginSet, endSet] = [endSet, beginSet] } const tempSet: Set = new Set() for (const word of beginSet) { diff --git a/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts b/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts index 3874716..ca97250 100644 --- a/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts +++ b/src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts @@ -1,7 +1,7 @@ // #Medium #Depth_First_Search #Tree #Binary_Tree #Top_Interview_150_Binary_Tree_General // #2025_04_07_Time_0_ms_(100.00%)_Space_57.72_MB_(19.07%) -import { TreeNode } from "../../com_github_leetcode/treenode" +import { TreeNode } from '../../com_github_leetcode/treenode' /** * Definition for a binary tree node. diff --git a/src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts b/src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts index 653e9ec..7c7ff33 100644 --- a/src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts +++ b/src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts @@ -5,8 +5,8 @@ function singleNumber(nums: number[]): number { let ones = 0 let twos = 0 for (const num of nums) { - ones = (ones ^ num) & (~twos) - twos = (twos ^ num) & (~ones) + ones = (ones ^ num) & ~twos + twos = (twos ^ num) & ~ones } return ones } diff --git a/src/test/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.test.ts b/src/test/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.test.ts index 1cae0eb..a123294 100644 --- a/src/test/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.test.ts +++ b/src/test/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.test.ts @@ -4,9 +4,9 @@ import { sumNumbers } from 'src/main/ts/g0101_0200/s0129_sum_root_to_leaf_number import { expect, test } from 'vitest' test('sumNumbers', () => { - expect(sumNumbers(createTreeNode([1,2,3]))).toEqual(25) + expect(sumNumbers(createTreeNode([1, 2, 3]))).toEqual(25) }) test('sumNumbers2', () => { - expect(sumNumbers(createTreeNode([4,9,0,5,1]))).toEqual(1026) + expect(sumNumbers(createTreeNode([4, 9, 0, 5, 1]))).toEqual(1026) }) From 4cb99fabf44e5b0bd0f1e4d96121133cb5788e8f Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Tue, 8 Apr 2025 08:52:21 +0300 Subject: [PATCH 33/49] Updated LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 5bebe5b..bcf7a79 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023-2024 Valentyn Kolesnikov +Copyright (c) 2023-2025 Valentyn Kolesnikov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 656c33898c799f5929ace5a74571b0eed508df05 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Tue, 8 Apr 2025 23:38:59 +0700 Subject: [PATCH 34/49] Added tasks 149-167 --- README.md | 17 ++++++ .../s0149_max_points_on_a_line/readme.md | 28 ++++++++++ .../s0149_max_points_on_a_line/solution.ts | 31 +++++++++++ .../readme.md | 48 +++++++++++++++++ .../solution.ts | 24 +++++++++ .../s0151_reverse_words_in_a_string/readme.md | 53 +++++++++++++++++++ .../solution.ts | 13 +++++ .../s0162_find_peak_element/readme.md | 33 ++++++++++++ .../s0162_find_peak_element/solution.ts | 19 +++++++ .../readme.md | 41 ++++++++++++++ .../solution.ts | 21 ++++++++ .../solution.test.ts | 11 ++++ .../solution.test.ts | 15 ++++++ .../solution.test.ts | 15 ++++++ .../s0162_find_peak_element/solution.test.ts | 11 ++++ .../solution.test.ts | 15 ++++++ 16 files changed, 395 insertions(+) create mode 100644 src/main/ts/g0101_0200/s0149_max_points_on_a_line/readme.md create mode 100644 src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts create mode 100644 src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/readme.md create mode 100644 src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts create mode 100644 src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/readme.md create mode 100644 src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts create mode 100644 src/main/ts/g0101_0200/s0162_find_peak_element/readme.md create mode 100644 src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts create mode 100644 src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/readme.md create mode 100644 src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts create mode 100644 src/test/ts/g0101_0200/s0149_max_points_on_a_line/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0162_find_peak_element/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.test.ts diff --git a/README.md b/README.md index 4ba55e8..20ecd15 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0167 |[Two Sum II - Input Array Is Sorted](src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts)| Medium | Array, Binary_Search, Two_Pointers | 0 | 100.00 #### Day 8 @@ -160,6 +161,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search | 0 | 100.00 #### Day 13 @@ -410,6 +412,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0150 |[Evaluate Reverse Polish Notation](src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts)| Medium | Top_Interview_Questions, Array, Math, Stack | 1 | 97.48 | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 #### Day 4 @@ -871,6 +874,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 | 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 +| 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers | 0 | 100.00 #### Udemy Binary Search @@ -1033,6 +1037,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0012 |[Integer to Roman](src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts)| Medium | String, Hash_Table, Math | 3 | 93.02 | 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String | 0 | 100.00 | 0014 |[Longest Common Prefix](src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String | 0 | 100.00 +| 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers | 0 | 100.00 | 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 2 | 99.08 | 0028 |[Implement strStr()](src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 | 0068 |[Text Justification](src/main/ts/g0001_0100/s0068_text_justification/solution.ts)| Hard | Array, String, Simulation | 0 | 100.00 @@ -1042,6 +1047,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0125 |[Valid Palindrome](src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers | 0 | 100.00 +| 0167 |[Two Sum II - Input Array Is Sorted](src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts)| Medium | Array, Binary_Search, Two_Pointers | 0 | 100.00 | 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 @@ -1084,6 +1090,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 | 0071 |[Simplify Path](src/main/ts/g0001_0100/s0071_simplify_path/solution.ts)| Medium | String, Stack | 0 | 100.00 | 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 +| 0150 |[Evaluate Reverse Polish Notation](src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts)| Medium | Top_Interview_Questions, Array, Math, Stack | 1 | 97.48 #### Top Interview 150 Linked List @@ -1182,6 +1189,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search | 0 | 100.00 | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 @@ -1210,6 +1218,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 | 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Hard | Array, String, Simulation | 0 | 100.00 | 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 +| 0149 |[Max Points on a Line](src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 9 | 97.18 #### Top Interview 150 1D DP @@ -1475,6 +1484,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 +| 0167 |[Two Sum II - Input Array Is Sorted](src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts)| Medium | Array, Binary_Search, Two_Pointers | 0 | 100.00 #### Day 4 Two Pointers @@ -1556,6 +1566,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 +| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search | 0 | 100.00 #### Day 3 Two Pointers @@ -1671,6 +1682,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0149 |[Max Points on a Line](src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 9 | 97.18 ## Algorithms @@ -1710,10 +1722,15 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_3, Level_2_Day_12_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Algorithm_I_Day_2_Two_Pointers, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Data_Structure_II_Day_1_Array, Udemy_Famous_Algorithm, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0167 |[Two Sum II - Input Array Is Sorted](src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts)| Medium | Array, Binary_Search, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Binary_Search_I_Day_7, Top_Interview_150_Two_Pointers | 0 | 100.00 +| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_II_Day_12, Top_Interview_150_Binary_Search | 0 | 100.00 | 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_II_Day_11_Linked_List, Udemy_Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 65 | 72.36 | 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Data_Structure_II_Day_14_Stack_Queue, Programming_Skills_II_Day_18, Level_2_Day_16_Design, Udemy_Design, Top_Interview_150_Stack, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_I_Day_12, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 | 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Dynamic_Programming_I_Day_6, Level_2_Day_13_Dynamic_Programming, Udemy_Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers, Udemy_Strings, Top_Interview_150_Array/String | 0 | 100.00 +| 0150 |[Evaluate Reverse Polish Notation](src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts)| Medium | Top_Interview_Questions, Array, Math, Stack, Programming_Skills_II_Day_3, Top_Interview_150_Stack | 1 | 97.48 +| 0149 |[Max Points on a Line](src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry, Algorithm_II_Day_21_Others, Top_Interview_150_Math | 9 | 97.18 | 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Level_2_Day_4_Linked_List, Top_Interview_150_Divide_and_Conquer, Big_O_Time_O(log(N))_Space_O(log(N)) | 36 | 44.94 | 0146 |[LRU Cache](src/main/ts/g0101_0200/s0146_lru_cache/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 97 | 81.52 | 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_II_Day_10_Linked_List, Level_1_Day_4_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 51 | 76.99 diff --git a/src/main/ts/g0101_0200/s0149_max_points_on_a_line/readme.md b/src/main/ts/g0101_0200/s0149_max_points_on_a_line/readme.md new file mode 100644 index 0000000..99b2528 --- /dev/null +++ b/src/main/ts/g0101_0200/s0149_max_points_on_a_line/readme.md @@ -0,0 +1,28 @@ +149\. Max Points on a Line + +Hard + +Given an array of `points` where points[i] = [xi, yi] represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/02/25/plane1.jpg) + +**Input:** points = [[1,1],[2,2],[3,3]] + +**Output:** 3 + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2021/02/25/plane2.jpg) + +**Input:** points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]] + +**Output:** 4 + +**Constraints:** + +* `1 <= points.length <= 300` +* `points[i].length == 2` +* -104 <= xi, yi <= 104 +* All the `points` are **unique**. diff --git a/src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts b/src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts new file mode 100644 index 0000000..ce5d847 --- /dev/null +++ b/src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts @@ -0,0 +1,31 @@ +// #Hard #Top_Interview_Questions #Array #Hash_Table #Math #Geometry #Algorithm_II_Day_21_Others +// #Top_Interview_150_Math #2025_04_08_Time_9_ms_(97.18%)_Space_61.36_MB_(70.42%) + +function maxPoints(points: number[][]): number { + if (points.length <= 2) { + return points.length + } + const map = new Map() + let result: number = 0 + for (let i = 0; i < points.length; i++) { + const [x0, y0] = points[i] + for (let j = i + 1; j < points.length; j++) { + const [x1, y1] = points[j] + let m: number + if (x0 === x1) { + m = Number.MAX_VALUE + } else if (y0 === y1) { + m = 0 + } else { + m = (y0 - y1) / (x0 - x1) + } + const nextM: number = map.has(m) ? map.get(m) + 1 : 2 + map.set(m, nextM) + result = Math.max(result, nextM) + } + map.clear() + } + return result +} + +export { maxPoints } diff --git a/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/readme.md b/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/readme.md new file mode 100644 index 0000000..1369eac --- /dev/null +++ b/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/readme.md @@ -0,0 +1,48 @@ +150\. Evaluate Reverse Polish Notation + +Medium + +Evaluate the value of an arithmetic expression in [Reverse Polish Notation](http://en.wikipedia.org/wiki/Reverse_Polish_notation). + +Valid operators are `+`, `-`, `*`, and `/`. Each operand may be an integer or another expression. + +**Note** that division between two integers should truncate toward zero. + +It is guaranteed that the given RPN expression is always valid. That means the expression would always evaluate to a result, and there will not be any division by zero operation. + +**Example 1:** + +**Input:** tokens = ["2","1","+","3","\*"] + +**Output:** 9 + +**Explanation:** ((2 + 1) \* 3) = 9 + +**Example 2:** + +**Input:** tokens = ["4","13","5","/","+"] + +**Output:** 6 + +**Explanation:** (4 + (13 / 5)) = 6 + +**Example 3:** + +**Input:** tokens = ["10","6","9","3","+","-11","\*","/","\*","17","+","5","+"] + +**Output:** 22 + +**Explanation:** + + ((10 \* (6 / ((9 + 3) \* -11))) + 17) + 5 + = ((10 \* (6 / (12 \* -11))) + 17) + 5 + = ((10 \* (6 / -132)) + 17) + 5 + = ((10 \* 0) + 17) + 5 + = (0 + 17) + 5 + = 17 + 5 + = 22 + +**Constraints:** + +* 1 <= tokens.length <= 104 +* `tokens[i]` is either an operator: `"+"`, `"-"`, `"*"`, or `"/"`, or an integer in the range `[-200, 200]`. diff --git a/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts b/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts new file mode 100644 index 0000000..1e2ceda --- /dev/null +++ b/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts @@ -0,0 +1,24 @@ +// #Medium #Top_Interview_Questions #Array #Math #Stack #Programming_Skills_II_Day_3 +// #Top_Interview_150_Stack #2025_04_08_Time_1_ms_(97.48%)_Space_60.14_MB_(28.30%) + +function evalRPN(tokens: string[]): number { + const numberStack: number[] = [] + const isOperator = (val: string): boolean => val === '+' || val === '-' || val === '*' || val === '/' + for (let token of tokens) { + if (isOperator(token)) { + const right = numberStack.pop() as number + const left = numberStack.pop() as number + + if (token === '+') numberStack.push(left + right) + else if (token === '-') numberStack.push(left - right) + else if (token === '*') numberStack.push(left * right) + else if (token === '/') { + const result = left / right + numberStack.push(result < 0 ? Math.ceil(result) : Math.floor(result)) + } + } else numberStack.push(+token) + } + return numberStack.pop() || 0 +} + +export { evalRPN } diff --git a/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/readme.md b/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/readme.md new file mode 100644 index 0000000..1f89300 --- /dev/null +++ b/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/readme.md @@ -0,0 +1,53 @@ +151\. Reverse Words in a String + +Medium + +Given an input string `s`, reverse the order of the **words**. + +A **word** is defined as a sequence of non-space characters. The **words** in `s` will be separated by at least one space. + +Return _a string of the words in reverse order concatenated by a single space._ + +**Note** that `s` may contain leading or trailing spaces or multiple spaces between two words. The returned string should only have a single space separating the words. Do not include any extra spaces. + +**Example 1:** + +**Input:** s = "the sky is blue" + +**Output:** "blue is sky the" + +**Example 2:** + +**Input:** s = " hello world " + +**Output:** "world hello" + +**Explanation:** Your reversed string should not contain leading or trailing spaces. + +**Example 3:** + +**Input:** s = "a good example" + +**Output:** "example good a" + +**Explanation:** You need to reduce multiple spaces between two words to a single space in the reversed string. + +**Example 4:** + +**Input:** s = " Bob Loves Alice " + +**Output:** "Alice Loves Bob" + +**Example 5:** + +**Input:** s = "Alice does not even like bob" + +**Output:** "bob like even not does Alice" + +**Constraints:** + +* 1 <= s.length <= 104 +* `s` contains English letters (upper-case and lower-case), digits, and spaces `' '`. +* There is **at least one** word in `s`. + +**Follow-up:** If the string data type is mutable in your language, can you solve it **in-place** with `O(1)` extra space? diff --git a/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts b/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts new file mode 100644 index 0000000..8c4215f --- /dev/null +++ b/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts @@ -0,0 +1,13 @@ +// #Medium #String #Two_Pointers #Udemy_Strings #Top_Interview_150_Array/String +// #2025_04_08_Time_0_ms_(100.00%)_Space_57.70_MB_(48.75%) + +function reverseWords(s: string): string { + return s + ?.trim() + ?.replaceAll(/\s{2,}/g, ' ') + ?.split(' ') + ?.reverse() + .join(' ') +} + +export { reverseWords } diff --git a/src/main/ts/g0101_0200/s0162_find_peak_element/readme.md b/src/main/ts/g0101_0200/s0162_find_peak_element/readme.md new file mode 100644 index 0000000..abe70d7 --- /dev/null +++ b/src/main/ts/g0101_0200/s0162_find_peak_element/readme.md @@ -0,0 +1,33 @@ +162\. Find Peak Element + +Medium + +A peak element is an element that is strictly greater than its neighbors. + +Given an integer array `nums`, find a peak element, and return its index. If the array contains multiple peaks, return the index to **any of the peaks**. + +You may imagine that `nums[-1] = nums[n] = -∞`. + +You must write an algorithm that runs in `O(log n)` time. + +**Example 1:** + +**Input:** nums = [1,2,3,1] + +**Output:** 2 + +**Explanation:** 3 is a peak element and your function should return the index number 2. + +**Example 2:** + +**Input:** nums = [1,2,1,3,5,6,4] + +**Output:** 5 + +**Explanation:** Your function can return either index number 1 where the peak element is 2, or index number 5 where the peak element is 6. + +**Constraints:** + +* `1 <= nums.length <= 1000` +* -231 <= nums[i] <= 231 - 1 +* `nums[i] != nums[i + 1]` for all valid `i`. diff --git a/src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts b/src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts new file mode 100644 index 0000000..d79d342 --- /dev/null +++ b/src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts @@ -0,0 +1,19 @@ +// #Medium #Top_Interview_Questions #Array #Binary_Search #Algorithm_II_Day_2_Binary_Search +// #Binary_Search_II_Day_12 #Top_Interview_150_Binary_Search +// #2025_04_08_Time_0_ms_(100.00%)_Space_55.40_MB_(60.85%) + +function findPeakElement(nums: number[]): number { + let start = 0 + let end = nums.length - 1 + while (start < end) { + const mid = start + Math.floor((end - start) / 2) + if (nums[mid + 1] > nums[mid]) { + start = mid + 1 + } else { + end = mid + } + } + return start +} + +export { findPeakElement } diff --git a/src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/readme.md b/src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/readme.md new file mode 100644 index 0000000..238d405 --- /dev/null +++ b/src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/readme.md @@ -0,0 +1,41 @@ +167\. Two Sum II - Input Array Is Sorted + +Easy + +Given a **1-indexed** array of integers `numbers` that is already **_sorted in non-decreasing order_**, find two numbers such that they add up to a specific `target` number. Let these two numbers be numbers[index1] and numbers[index2] where 1 <= index1 < index2 <= numbers.length. + +Return _the indices of the two numbers,_ index1 _and_ index2_, **added by one** as an integer array_ [index1, index2] _of length 2._ + +The tests are generated such that there is **exactly one solution**. You **may not** use the same element twice. + +**Example 1:** + +**Input:** numbers = [2,7,11,15], target = 9 + +**Output:** [1,2] + +**Explanation:** The sum of 2 and 7 is 9. Therefore, index1 = 1, index2 = 2. We return [1, 2]. + +**Example 2:** + +**Input:** numbers = [2,3,4], target = 6 + +**Output:** [1,3] + +**Explanation:** The sum of 2 and 4 is 6. Therefore index1 = 1, index2 = 3. We return [1, 3]. + +**Example 3:** + +**Input:** numbers = [\-1,0], target = -1 + +**Output:** [1,2] + +**Explanation:** The sum of -1 and 0 is -1. Therefore index1 = 1, index2 = 2. We return [1, 2]. + +**Constraints:** + +* 2 <= numbers.length <= 3 * 104 +* `-1000 <= numbers[i] <= 1000` +* `numbers` is sorted in **non-decreasing order**. +* `-1000 <= target <= 1000` +* The tests are generated such that there is **exactly one solution**. diff --git a/src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts b/src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts new file mode 100644 index 0000000..ee66d03 --- /dev/null +++ b/src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts @@ -0,0 +1,21 @@ +// #Medium #Array #Binary_Search #Two_Pointers #Algorithm_I_Day_3_Two_Pointers +// #Binary_Search_I_Day_7 #Top_Interview_150_Two_Pointers +// #2025_04_08_Time_0_ms_(100.00%)_Space_56.49_MB_(68.78%) + +function twoSum(numbers: number[], target: number): number[] { + let i = 0 + let j = numbers.length - 1 + while (i < j) { + const sum = numbers[i] + numbers[j] + if (sum === target) { + return [i + 1, j + 1] + } else if (sum < target) { + i++ + } else { + j-- + } + } + return [] +} + +export { twoSum } diff --git a/src/test/ts/g0101_0200/s0149_max_points_on_a_line/solution.test.ts b/src/test/ts/g0101_0200/s0149_max_points_on_a_line/solution.test.ts new file mode 100644 index 0000000..84b5c45 --- /dev/null +++ b/src/test/ts/g0101_0200/s0149_max_points_on_a_line/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { maxPoints } from 'src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution' +import { expect, test } from 'vitest' + +test('maxPoints', () => { + expect(maxPoints([[1,1],[2,2],[3,3]])).toEqual(3) +}) + +test('maxPoints2', () => { + expect(maxPoints([[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]])).toEqual(4) +}) diff --git a/src/test/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.test.ts b/src/test/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.test.ts new file mode 100644 index 0000000..2a4048f --- /dev/null +++ b/src/test/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { evalRPN } from 'src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution' +import { expect, test } from 'vitest' + +test('evalRPN', () => { + expect(evalRPN(['2', '1', '+', '3', '*'])).toEqual(9) +}) + +test('evalRPN2', () => { + expect(evalRPN(['4', '13', '5', '/', '+'])).toEqual(6) +}) + +test('evalRPN3', () => { + expect(evalRPN(['10', '6', '9', '3', '+', '-11', '*', '/', '*', '17', '+', '5', '+'])).toEqual(22) +}) diff --git a/src/test/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.test.ts b/src/test/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.test.ts new file mode 100644 index 0000000..5477310 --- /dev/null +++ b/src/test/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { reverseWords } from 'src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution' +import { expect, test } from 'vitest' + +test('reverseWords', () => { + expect(reverseWords('the sky is blue')).toEqual('blue is sky the') +}) + +test('reverseWords2', () => { + expect(reverseWords(' hello world ')).toEqual('world hello') +}) + +test('reverseWords3', () => { + expect(reverseWords('a good example')).toEqual('example good a') +}) diff --git a/src/test/ts/g0101_0200/s0162_find_peak_element/solution.test.ts b/src/test/ts/g0101_0200/s0162_find_peak_element/solution.test.ts new file mode 100644 index 0000000..b6fedd9 --- /dev/null +++ b/src/test/ts/g0101_0200/s0162_find_peak_element/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { findPeakElement } from 'src/main/ts/g0101_0200/s0162_find_peak_element/solution' +import { expect, test } from 'vitest' + +test('findPeakElement', () => { + expect(findPeakElement([1,2,3,1])).toEqual(2) +}) + +test('findPeakElement2', () => { + expect(findPeakElement([1,2,1,3,5,6,4])).toEqual(5) +}) diff --git a/src/test/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.test.ts b/src/test/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.test.ts new file mode 100644 index 0000000..58aea70 --- /dev/null +++ b/src/test/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { twoSum } from 'src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution' +import { expect, test } from 'vitest' + +test('twoSum', () => { + expect(twoSum([2, 7, 11, 15], 9)).toEqual([1, 2]) +}) + +test('twoSum2', () => { + expect(twoSum([2, 3, 4], 6)).toEqual([1, 3]) +}) + +test('twoSum3', () => { + expect(twoSum([-1, 0], -1)).toEqual([1, 2]) +}) From 584c2f12277ee7c5cf12b96838e79fb2c103b3c3 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Wed, 9 Apr 2025 01:47:33 +0300 Subject: [PATCH 35/49] Improved tasks 149, 162 --- .../solution.test.ts | 19 +++++++++++++++++-- .../s0162_find_peak_element/solution.test.ts | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/test/ts/g0101_0200/s0149_max_points_on_a_line/solution.test.ts b/src/test/ts/g0101_0200/s0149_max_points_on_a_line/solution.test.ts index 84b5c45..2934c36 100644 --- a/src/test/ts/g0101_0200/s0149_max_points_on_a_line/solution.test.ts +++ b/src/test/ts/g0101_0200/s0149_max_points_on_a_line/solution.test.ts @@ -3,9 +3,24 @@ import { maxPoints } from 'src/main/ts/g0101_0200/s0149_max_points_on_a_line/sol import { expect, test } from 'vitest' test('maxPoints', () => { - expect(maxPoints([[1,1],[2,2],[3,3]])).toEqual(3) + expect( + maxPoints([ + [1, 1], + [2, 2], + [3, 3], + ]), + ).toEqual(3) }) test('maxPoints2', () => { - expect(maxPoints([[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]])).toEqual(4) + expect( + maxPoints([ + [1, 1], + [3, 2], + [5, 3], + [4, 1], + [2, 3], + [1, 4], + ]), + ).toEqual(4) }) diff --git a/src/test/ts/g0101_0200/s0162_find_peak_element/solution.test.ts b/src/test/ts/g0101_0200/s0162_find_peak_element/solution.test.ts index b6fedd9..74ece3c 100644 --- a/src/test/ts/g0101_0200/s0162_find_peak_element/solution.test.ts +++ b/src/test/ts/g0101_0200/s0162_find_peak_element/solution.test.ts @@ -3,9 +3,9 @@ import { findPeakElement } from 'src/main/ts/g0101_0200/s0162_find_peak_element/ import { expect, test } from 'vitest' test('findPeakElement', () => { - expect(findPeakElement([1,2,3,1])).toEqual(2) + expect(findPeakElement([1, 2, 3, 1])).toEqual(2) }) test('findPeakElement2', () => { - expect(findPeakElement([1,2,1,3,5,6,4])).toEqual(5) + expect(findPeakElement([1, 2, 1, 3, 5, 6, 4])).toEqual(5) }) From 315ad0ce458794bd8e812c926c92bdaa707db96b Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Wed, 9 Apr 2025 19:57:19 +0700 Subject: [PATCH 36/49] Added tasks 172-191 --- README.md | 19 ++++++ .../s0172_factorial_trailing_zeroes/readme.md | 35 ++++++++++ .../solution.ts | 14 ++++ .../readme.md | 44 +++++++++++++ .../solution.ts | 66 +++++++++++++++++++ .../readme.md | 31 +++++++++ .../solution.ts | 18 +++++ .../g0101_0200/s0190_reverse_bits/readme.md | 32 +++++++++ .../g0101_0200/s0190_reverse_bits/solution.ts | 15 +++++ .../s0191_number_of_1_bits/readme.md | 40 +++++++++++ .../s0191_number_of_1_bits/solution.ts | 15 +++++ .../solution.test.ts | 15 +++++ .../solution.test.ts | 17 +++++ .../solution.test.ts | 11 ++++ .../s0190_reverse_bits/solution.test.ts | 11 ++++ .../s0191_number_of_1_bits/solution.test.ts | 15 +++++ 16 files changed, 398 insertions(+) create mode 100644 src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/readme.md create mode 100644 src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts create mode 100644 src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/readme.md create mode 100644 src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts create mode 100644 src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/readme.md create mode 100644 src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.ts create mode 100644 src/main/ts/g0101_0200/s0190_reverse_bits/readme.md create mode 100644 src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts create mode 100644 src/main/ts/g0101_0200/s0191_number_of_1_bits/readme.md create mode 100644 src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts create mode 100644 src/test/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0190_reverse_bits/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0191_number_of_1_bits/solution.test.ts diff --git a/README.md b/README.md index 20ecd15..e005019 100644 --- a/README.md +++ b/README.md @@ -342,6 +342,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 #### Day 3 Conditional Statements @@ -489,6 +490,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0061 |[Rotate List](src/main/ts/g0001_0100/s0061_rotate_list/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0173 |[Binary Search Tree Iterator](src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 6 | 98.16 #### Day 17 @@ -784,6 +786,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 | 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0173 |[Binary Search Tree Iterator](src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 6 | 98.16 #### Day 10 Graph/BFS/DFS @@ -862,6 +865,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 53 | 83.14 | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 +| 0172 |[Factorial Trailing Zeroes](src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts)| Medium | Top_Interview_Questions, Math | 0 | 100.00 | 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 #### Udemy Strings @@ -1005,6 +1009,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 +| 0190 |[Reverse Bits](src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 34 | 99.74 | 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 1 | 89.22 #### Udemy Design @@ -1122,6 +1128,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0112 |[Path Sum](src/main/ts/g0101_0200/s0112_path_sum/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0129 |[Sum Root to Leaf Numbers](src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 +| 0173 |[Binary Search Tree Iterator](src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 6 | 98.16 | 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 #### Top Interview 150 Binary Tree BFS @@ -1207,6 +1214,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0067 |[Add Binary](src/main/ts/g0001_0100/s0067_add_binary/solution.ts)| Easy | String, Math, Bit_Manipulation, Simulation | 0 | 100.00 +| 0190 |[Reverse Bits](src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 34 | 99.74 +| 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0137 |[Single Number II](src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts)| Medium | Array, Bit_Manipulation | 0 | 100.00 @@ -1216,6 +1225,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 +| 0172 |[Factorial Trailing Zeroes](src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts)| Medium | Top_Interview_Questions, Math | 0 | 100.00 | 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Hard | Array, String, Simulation | 0 | 100.00 | 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 | 0149 |[Max Points on a Line](src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 9 | 97.18 @@ -1241,6 +1251,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0097 |[Interleaving String](src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts)| Medium | String, Dynamic_Programming | 43 | 97.65 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0123 |[Best Time to Buy and Sell Stock III](src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts)| Hard | Array, Dynamic_Programming | 5 | 85.07 +| 0188 |[Best Time to Buy and Sell Stock IV](src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.ts)| Hard | Array, Dynamic_Programming | 0 | 100.00 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 ### Data Structure I @@ -1441,6 +1452,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0173 |[Binary Search Tree Iterator](src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 6 | 98.16 #### Day 18 Tree @@ -1544,11 +1556,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 #### Day 14 Bit Manipulation | | | | | | |-|-|-|-|-|- +| 0190 |[Reverse Bits](src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 34 | 99.74 | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 ### Algorithm II @@ -1720,7 +1734,12 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_8_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 | 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search, Graph_Theory_I_Day_1_Matrix_Related_Problems, Level_1_Day_9_Graph/BFS/DFS, Udemy_Graph, Top_Interview_150_Graph_General, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_3, Level_2_Day_12_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Algorithm_I_Day_13_Bit_Manipulation, Programming_Skills_I_Day_2_Operator, Udemy_Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 0 | 100.00 +| 0190 |[Reverse Bits](src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 34 | 99.74 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Algorithm_I_Day_2_Two_Pointers, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 +| 0188 |[Best Time to Buy and Sell Stock IV](src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.ts)| Hard | Array, Dynamic_Programming, Top_Interview_150_Multidimensional_DP | 0 | 100.00 +| 0173 |[Binary Search Tree Iterator](src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator, Data_Structure_II_Day_17_Tree, Programming_Skills_II_Day_16, Level_2_Day_9_Binary_Search_Tree, Top_Interview_150_Binary_Tree_General | 6 | 98.16 +| 0172 |[Factorial Trailing Zeroes](src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts)| Medium | Top_Interview_Questions, Math, Udemy_Integers, Top_Interview_150_Math | 0 | 100.00 | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Data_Structure_II_Day_1_Array, Udemy_Famous_Algorithm, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0167 |[Two Sum II - Input Array Is Sorted](src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts)| Medium | Array, Binary_Search, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Binary_Search_I_Day_7, Top_Interview_150_Two_Pointers | 0 | 100.00 | 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_II_Day_12, Top_Interview_150_Binary_Search | 0 | 100.00 diff --git a/src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/readme.md b/src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/readme.md new file mode 100644 index 0000000..1ac6005 --- /dev/null +++ b/src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/readme.md @@ -0,0 +1,35 @@ +172\. Factorial Trailing Zeroes + +Medium + +Given an integer `n`, return _the number of trailing zeroes in_ `n!`. + +Note that `n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1`. + +**Example 1:** + +**Input:** n = 3 + +**Output:** 0 + +**Explanation:** 3! = 6, no trailing zero. + +**Example 2:** + +**Input:** n = 5 + +**Output:** 1 + +**Explanation:** 5! = 120, one trailing zero. + +**Example 3:** + +**Input:** n = 0 + +**Output:** 0 + +**Constraints:** + +* 0 <= n <= 104 + +**Follow up:** Could you write a solution that works in logarithmic time complexity? diff --git a/src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts b/src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts new file mode 100644 index 0000000..1ee679a --- /dev/null +++ b/src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts @@ -0,0 +1,14 @@ +// #Medium #Top_Interview_Questions #Math #Udemy_Integers #Top_Interview_150_Math +// #2025_04_09_Time_0_ms_(100.00%)_Space_55.76_MB_(76.26%) + +function trailingZeroes(n: number): number { + let base = 5 + let count = 0 + while (n >= base) { + count += Math.floor(n / base) + base *= 5 + } + return count +} + +export { trailingZeroes } diff --git a/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/readme.md b/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/readme.md new file mode 100644 index 0000000..0e628a7 --- /dev/null +++ b/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/readme.md @@ -0,0 +1,44 @@ +173\. Binary Search Tree Iterator + +Medium + +Implement the `BSTIterator` class that represents an iterator over the **[in-order traversal](https://en.wikipedia.org/wiki/Tree_traversal#In-order_(LNR))** of a binary search tree (BST): + +* `BSTIterator(TreeNode root)` Initializes an object of the `BSTIterator` class. The `root` of the BST is given as part of the constructor. The pointer should be initialized to a non-existent number smaller than any element in the BST. +* `boolean hasNext()` Returns `true` if there exists a number in the traversal to the right of the pointer, otherwise returns `false`. +* `int next()` Moves the pointer to the right, then returns the number at the pointer. + +Notice that by initializing the pointer to a non-existent smallest number, the first call to `next()` will return the smallest element in the BST. + +You may assume that `next()` calls will always be valid. That is, there will be at least a next number in the in-order traversal when `next()` is called. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2018/12/25/bst-tree.png) + +**Input** ["BSTIterator", "next", "next", "hasNext", "next", "hasNext", "next", "hasNext", "next", "hasNext"] [[[7, 3, 15, null, null, 9, 20]], [], [], [], [], [], [], [], [], []] + +**Output:** [null, 3, 7, true, 9, true, 15, true, 20, false] + +**Explanation:** + + BSTIterator bSTIterator = new BSTIterator([7, 3, 15, null, null, 9, 20]); + bSTIterator.next(); // return 3 + bSTIterator.next(); // return 7 + bSTIterator.hasNext(); // return True + bSTIterator.next(); // return 9 + bSTIterator.hasNext(); // return True + bSTIterator.next(); // return 15 + bSTIterator.hasNext(); // return True + bSTIterator.next(); // return 20 + bSTIterator.hasNext(); // return False + +**Constraints:** + +* The number of nodes in the tree is in the range [1, 105]. +* 0 <= Node.val <= 106 +* At most 105 calls will be made to `hasNext`, and `next`. + +**Follow up:** + +* Could you implement `next()` and `hasNext()` to run in average `O(1)` time and use `O(h)` memory, where `h` is the height of the tree? diff --git a/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts b/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts new file mode 100644 index 0000000..2454b58 --- /dev/null +++ b/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts @@ -0,0 +1,66 @@ +// #Medium #Tree #Binary_Tree #Stack #Design #Binary_Search_Tree #Iterator +// #Data_Structure_II_Day_17_Tree #Programming_Skills_II_Day_16 #Level_2_Day_9_Binary_Search_Tree +// #Top_Interview_150_Binary_Tree_General #2025_04_09_Time_6_ms_(98.16%)_Space_69.76_MB_(29.04%) + +import { TreeNode } from "../../com_github_leetcode/treenode"; + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +class BSTIterator { + private node: TreeNode | null; + + constructor(root: TreeNode | null) { + this.node = root; + } + + next(): number { + let res = -1; + while (this.node !== null) { + if (this.node.left !== null) { + let rightMost = this.node.left; + while (rightMost.right !== null && rightMost.right !== this.node) { + rightMost = rightMost.right; + } + + if (rightMost.right === null) { + rightMost.right = this.node; + this.node = this.node.left; + } else { + rightMost.right = null; + res = this.node.val; + this.node = this.node.right; + return res; + } + } else { + res = this.node.val; + this.node = this.node.right; + return res; + } + } + return res; + } + + hasNext(): boolean { + return this.node !== null; + } +} + +/** + * Your BSTIterator object will be instantiated and called as such: + * var obj = new BSTIterator(root) + * var param_1 = obj.next() + * var param_2 = obj.hasNext() + */ + +export { BSTIterator } diff --git a/src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/readme.md b/src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/readme.md new file mode 100644 index 0000000..23e753c --- /dev/null +++ b/src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/readme.md @@ -0,0 +1,31 @@ +188\. Best Time to Buy and Sell Stock IV + +Hard + +You are given an integer array `prices` where `prices[i]` is the price of a given stock on the ith day, and an integer `k`. + +Find the maximum profit you can achieve. You may complete at most `k` transactions. + +**Note:** You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again). + +**Example 1:** + +**Input:** k = 2, prices = [2,4,1] + +**Output:** 2 + +**Explanation:** Buy on day 1 (price = 2) and sell on day 2 (price = 4), profit = 4-2 = 2. + +**Example 2:** + +**Input:** k = 2, prices = [3,2,6,5,0,3] + +**Output:** 7 + +**Explanation:** Buy on day 2 (price = 2) and sell on day 3 (price = 6), profit = 6-2 = 4. Then buy on day 5 (price = 0) and sell on day 6 (price = 3), profit = 3-0 = 3. + +**Constraints:** + +* `0 <= k <= 100` +* `0 <= prices.length <= 1000` +* `0 <= prices[i] <= 1000` diff --git a/src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.ts b/src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.ts new file mode 100644 index 0000000..7c9c13f --- /dev/null +++ b/src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.ts @@ -0,0 +1,18 @@ +// #Hard #Array #Dynamic_Programming #Top_Interview_150_Multidimensional_DP +// #2025_04_09_Time_0_ms_(100.00%)_Space_58.46_MB_(61.74%) + +function maxProfit(k: number, prices: number[]): number { + const n = prices.length + const dp: number[] = new Array(k + 1).fill(0) + const maxdp: number[] = new Array(k + 1).fill(Number.MIN_SAFE_INTEGER) + for (let i = 1; i <= n; i++) { + maxdp[0] = Math.max(maxdp[0], dp[0] - prices[i - 1]) + for (let j = k; j >= 1; j--) { + maxdp[j] = Math.max(maxdp[j], dp[j] - prices[i - 1]) + dp[j] = Math.max(dp[j], maxdp[j - 1] + prices[i - 1]) + } + } + return dp[k] +} + +export { maxProfit } diff --git a/src/main/ts/g0101_0200/s0190_reverse_bits/readme.md b/src/main/ts/g0101_0200/s0190_reverse_bits/readme.md new file mode 100644 index 0000000..6d126df --- /dev/null +++ b/src/main/ts/g0101_0200/s0190_reverse_bits/readme.md @@ -0,0 +1,32 @@ +190\. Reverse Bits + +Easy + +Reverse bits of a given 32 bits unsigned integer. + +**Note:** + +* Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned. +* In Java, the compiler represents the signed integers using [2's complement notation](https://en.wikipedia.org/wiki/Two%27s_complement). Therefore, in **Example 2** above, the input represents the signed integer `-3` and the output represents the signed integer `-1073741825`. + +**Example 1:** + +**Input:** n = 00000010100101000001111010011100 + +**Output:** 964176192 (00111001011110000010100101000000) + +**Explanation:** The input binary string **00000010100101000001111010011100** represents the unsigned integer 43261596, so return 964176192 which its binary representation is **00111001011110000010100101000000**. + +**Example 2:** + +**Input:** n = 11111111111111111111111111111101 + +**Output:** 3221225471 (10111111111111111111111111111111) + +**Explanation:** The input binary string **11111111111111111111111111111101** represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is **10111111111111111111111111111111**. + +**Constraints:** + +* The input must be a **binary string** of length `32` + +**Follow up:** If this function is called many times, how would you optimize it? diff --git a/src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts b/src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts new file mode 100644 index 0000000..05e537d --- /dev/null +++ b/src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts @@ -0,0 +1,15 @@ +// #Easy #Top_Interview_Questions #Bit_Manipulation #Divide_and_Conquer +// #Algorithm_I_Day_14_Bit_Manipulation #Udemy_Bit_Manipulation #Top_Interview_150_Bit_Manipulation +// #2025_04_09_Time_34_ms_(99.74%)_Space_57.96_MB_(41.00%) + +function reverseBits(n: number): number { + let reversed = 0 + for (let i = 0; i < 32; i++) { + reversed <<= 1 + reversed = reversed | (n & 1) + n >>>= 1 + } + return reversed >>> 0 +} + +export { reverseBits } diff --git a/src/main/ts/g0101_0200/s0191_number_of_1_bits/readme.md b/src/main/ts/g0101_0200/s0191_number_of_1_bits/readme.md new file mode 100644 index 0000000..4014868 --- /dev/null +++ b/src/main/ts/g0101_0200/s0191_number_of_1_bits/readme.md @@ -0,0 +1,40 @@ +191\. Number of 1 Bits + +Easy + +Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)). + +**Note:** + +* Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned. +* In Java, the compiler represents the signed integers using [2's complement notation](https://en.wikipedia.org/wiki/Two%27s_complement). Therefore, in **Example 3**, the input represents the signed integer. `-3`. + +**Example 1:** + +**Input:** n = 00000000000000000000000000001011 + +**Output:** 3 + +**Explanation:** The input binary string **00000000000000000000000000001011** has a total of three '1' bits. + +**Example 2:** + +**Input:** n = 00000000000000000000000010000000 + +**Output:** 1 + +**Explanation:** The input binary string **00000000000000000000000010000000** has a total of one '1' bit. + +**Example 3:** + +**Input:** n = 11111111111111111111111111111101 + +**Output:** 31 + +**Explanation:** The input binary string **11111111111111111111111111111101** has a total of thirty one '1' bits. + +**Constraints:** + +* The input must be a **binary string** of length `32`. + +**Follow up:** If this function is called many times, how would you optimize it? diff --git a/src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts b/src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts new file mode 100644 index 0000000..0ce05ed --- /dev/null +++ b/src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts @@ -0,0 +1,15 @@ +// #Easy #Top_Interview_Questions #Bit_Manipulation #Algorithm_I_Day_13_Bit_Manipulation +// #Programming_Skills_I_Day_2_Operator #Udemy_Bit_Manipulation #Top_Interview_150_Bit_Manipulation +// #2025_04_09_Time_0_ms_(100.00%)_Space_55.90_MB_(75.68%) + +function hammingWeight(n: number): number { + let sum = 0 + n = n >>> 0 + while (n > 0) { + sum += n % 2 + n = Math.floor(n / 2) + } + return sum +} + +export { hammingWeight } diff --git a/src/test/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.test.ts b/src/test/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.test.ts new file mode 100644 index 0000000..c555973 --- /dev/null +++ b/src/test/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { trailingZeroes } from 'src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution' +import { expect, test } from 'vitest' + +test('trailingZeroes', () => { + expect(trailingZeroes(3)).toEqual(0) +}) + +test('trailingZeroes2', () => { + expect(trailingZeroes(5)).toEqual(1) +}) + +test('trailingZeroe3', () => { + expect(trailingZeroes(0)).toEqual(0) +}) diff --git a/src/test/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.test.ts b/src/test/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.test.ts new file mode 100644 index 0000000..433ad23 --- /dev/null +++ b/src/test/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.test.ts @@ -0,0 +1,17 @@ +// tslint:disable:no-magic-numbers +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' +import { BSTIterator } from 'src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution' +import { expect, test } from 'vitest' + +test('bSTIterator', () => { + const bSTIterator = new BSTIterator(createTreeNode([7, 3, 15, null, null, 9, 20])) + expect(bSTIterator.next()).toEqual(3) + expect(bSTIterator.next()).toEqual(7) + expect(bSTIterator.hasNext()).toBeTruthy() + expect(bSTIterator.next()).toEqual(9) + expect(bSTIterator.hasNext()).toBeTruthy() + expect(bSTIterator.next()).toEqual(15) + expect(bSTIterator.hasNext()).toBeTruthy() + expect(bSTIterator.next()).toEqual(20) + expect(bSTIterator.hasNext()).toBeFalsy() +}) diff --git a/src/test/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.test.ts b/src/test/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.test.ts new file mode 100644 index 0000000..4225084 --- /dev/null +++ b/src/test/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { maxProfit } from 'src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution' +import { expect, test } from 'vitest' + +test('maxProfit', () => { + expect(maxProfit(2, [2, 4, 1])).toEqual(2) +}) + +test('maxProfit2', () => { + expect(maxProfit(2, [3, 2, 6, 5, 0, 3])).toEqual(7) +}) diff --git a/src/test/ts/g0101_0200/s0190_reverse_bits/solution.test.ts b/src/test/ts/g0101_0200/s0190_reverse_bits/solution.test.ts new file mode 100644 index 0000000..27cac28 --- /dev/null +++ b/src/test/ts/g0101_0200/s0190_reverse_bits/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { reverseBits } from 'src/main/ts/g0101_0200/s0190_reverse_bits/solution' +import { expect, test } from 'vitest' + +test('reverseBits', () => { + expect(reverseBits(0b00000010100101000001111010011100)).toEqual(964176192) +}) + +test('reverseBits2', () => { + expect(reverseBits(0b11111111111111111111111111111101)).toEqual(3221225471) +}) diff --git a/src/test/ts/g0101_0200/s0191_number_of_1_bits/solution.test.ts b/src/test/ts/g0101_0200/s0191_number_of_1_bits/solution.test.ts new file mode 100644 index 0000000..5cf7530 --- /dev/null +++ b/src/test/ts/g0101_0200/s0191_number_of_1_bits/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { hammingWeight } from 'src/main/ts/g0101_0200/s0191_number_of_1_bits/solution' +import { expect, test } from 'vitest' + +test('hammingWeight', () => { + expect(hammingWeight(11)).toEqual(3) +}) + +test('hammingWeight2', () => { + expect(hammingWeight(128)).toEqual(1) +}) + +test('hammingWeight3', () => { + expect(hammingWeight(2147483645)).toEqual(30) +}) From 3e6bea577c10f3400a2240f568506d3a2b075c8e Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Thu, 10 Apr 2025 23:29:33 +0700 Subject: [PATCH 37/49] Added tasks 199-209 --- README.md | 19 +++++++++ .../readme.md | 30 ++++++++++++++ .../solution.ts | 35 +++++++++++++++++ .../readme.md | 27 +++++++++++++ .../solution.ts | 18 +++++++++ .../g0201_0300/s0202_happy_number/readme.md | 39 +++++++++++++++++++ .../g0201_0300/s0202_happy_number/solution.ts | 23 +++++++++++ .../s0205_isomorphic_strings/readme.md | 33 ++++++++++++++++ .../s0205_isomorphic_strings/solution.ts | 23 +++++++++++ .../s0209_minimum_size_subarray_sum/readme.md | 33 ++++++++++++++++ .../solution.ts | 29 ++++++++++++++ .../solution.test.ts | 20 ++++++++++ .../solution.test.ts | 15 +++++++ .../s0202_happy_number/solution.test.ts | 11 ++++++ .../s0205_isomorphic_strings/solution.test.ts | 15 +++++++ .../solution.test.ts | 15 +++++++ 16 files changed, 385 insertions(+) create mode 100644 src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/readme.md create mode 100644 src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts create mode 100644 src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/readme.md create mode 100644 src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.ts create mode 100644 src/main/ts/g0201_0300/s0202_happy_number/readme.md create mode 100644 src/main/ts/g0201_0300/s0202_happy_number/solution.ts create mode 100644 src/main/ts/g0201_0300/s0205_isomorphic_strings/readme.md create mode 100644 src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts create mode 100644 src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/readme.md create mode 100644 src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts create mode 100644 src/test/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0202_happy_number/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0205_isomorphic_strings/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.test.ts diff --git a/README.md b/README.md index e005019..e72f8a0 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0209 |[Minimum Size Subarray Sum](src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 2 | 88.11 #### Day 2 @@ -353,6 +354,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0202 |[Happy Number](src/main/ts/g0201_0300/s0202_happy_number/solution.ts)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 #### Day 5 Function @@ -650,6 +652,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0205 |[Isomorphic Strings](src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts)| Easy | String, Hash_Table | 3 | 96.02 #### Day 3 Linked List @@ -734,6 +737,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0202 |[Happy Number](src/main/ts/g0201_0300/s0202_happy_number/solution.ts)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 | 0054 |[Spiral Matrix](src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 #### Day 2 String @@ -824,6 +828,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 #### Day 16 Design @@ -1061,6 +1066,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0209 |[Minimum Size Subarray Sum](src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 2 | 88.11 | 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 | 0030 |[Substring with Concatenation of All Words](src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts)| Hard | String, Hash_Table, Sliding_Window | 13 | 97.44 | 0076 |[Minimum Window Substring](src/main/ts/g0001_0100/s0076_minimum_window_substring/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 20 | 90.35 @@ -1078,8 +1084,10 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0205 |[Isomorphic Strings](src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts)| Easy | String, Hash_Table | 3 | 96.02 | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 +| 0202 |[Happy Number](src/main/ts/g0201_0300/s0202_happy_number/solution.ts)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 | 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 34 | 90.07 #### Top Interview 150 Intervals @@ -1135,6 +1143,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 @@ -1218,6 +1227,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0137 |[Single Number II](src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts)| Medium | Array, Bit_Manipulation | 0 | 100.00 +| 0201 |[Bitwise AND of Numbers Range](src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.ts)| Medium | Bit_Manipulation | 2 | 99.12 #### Top Interview 150 Math @@ -1446,6 +1456,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 #### Day 17 Tree @@ -1600,6 +1611,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 +| 0209 |[Minimum Size Subarray Sum](src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 2 | 88.11 #### Day 6 Breadth First Search Depth First Search @@ -1686,6 +1698,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0201 |[Bitwise AND of Numbers Range](src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.ts)| Medium | Bit_Manipulation | 2 | 99.12 #### Day 20 Others @@ -1696,6 +1709,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0202 |[Happy Number](src/main/ts/g0201_0300/s0202_happy_number/solution.ts)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 | 0149 |[Max Points on a Line](src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 9 | 97.18 ## Algorithms @@ -1729,10 +1743,15 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Level_2_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 | 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Data_Structure_II_Day_20_Heap_Priority_Queue, Top_Interview_150_Heap, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 +| 0209 |[Minimum Size Subarray Sum](src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Binary_Search_II_Day_1, Top_Interview_150_Sliding_Window | 2 | 88.11 | 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Level_2_Day_16_Design, Udemy_Trie_and_Heap, Top_Interview_150_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 | 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Top_Interview_150_Graph_General, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 | 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_8_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0205 |[Isomorphic Strings](src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts)| Easy | String, Hash_Table, Level_1_Day_2_String, Top_Interview_150_Hashmap | 3 | 96.02 +| 0202 |[Happy Number](src/main/ts/g0201_0300/s0202_happy_number/solution.ts)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers, Algorithm_II_Day_21_Others, Programming_Skills_I_Day_4_Loop, Level_2_Day_1_Implementation/Simulation, Top_Interview_150_Hashmap | 0 | 100.00 +| 0201 |[Bitwise AND of Numbers Range](src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.ts)| Medium | Bit_Manipulation, Algorithm_II_Day_19_Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 2 | 99.12 | 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search, Graph_Theory_I_Day_1_Matrix_Related_Problems, Level_1_Day_9_Graph/BFS/DFS, Udemy_Graph, Top_Interview_150_Graph_General, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 +| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_16_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_BFS | 0 | 100.00 | 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_3, Level_2_Day_12_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Algorithm_I_Day_13_Bit_Manipulation, Programming_Skills_I_Day_2_Operator, Udemy_Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 0 | 100.00 | 0190 |[Reverse Bits](src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 34 | 99.74 diff --git a/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/readme.md b/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/readme.md new file mode 100644 index 0000000..b3cb904 --- /dev/null +++ b/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/readme.md @@ -0,0 +1,30 @@ +199\. Binary Tree Right Side View + +Medium + +Given the `root` of a binary tree, imagine yourself standing on the **right side** of it, return _the values of the nodes you can see ordered from top to bottom_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/02/14/tree.jpg) + +**Input:** root = [1,2,3,null,5,null,4] + +**Output:** [1,3,4] + +**Example 2:** + +**Input:** root = [1,null,3] + +**Output:** [1,3] + +**Example 3:** + +**Input:** root = [] + +**Output:** [] + +**Constraints:** + +* The number of nodes in the tree is in the range `[0, 100]`. +* `-100 <= Node.val <= 100` diff --git a/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts b/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts new file mode 100644 index 0000000..7011329 --- /dev/null +++ b/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts @@ -0,0 +1,35 @@ +// #Medium #Top_100_Liked_Questions #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree +// #Data_Structure_II_Day_16_Tree #Level_2_Day_15_Tree #Top_Interview_150_Binary_Tree_BFS +// #2025_04_10_Time_0_ms_(100.00%)_Space_56.98_MB_(73.71%) + +import { TreeNode } from '../../com_github_leetcode/treenode' + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +function rightSideView(root: TreeNode | null): number[] { + const result: number[] = [] + function recurse(node: TreeNode | null, level: number): void { + if (node !== null) { + if (result.length === level) { + result.push(node.val) + } + recurse(node.right, level + 1) + recurse(node.left, level + 1) + } + } + recurse(root, 0) + return result +} + +export { rightSideView } diff --git a/src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/readme.md b/src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/readme.md new file mode 100644 index 0000000..879520b --- /dev/null +++ b/src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/readme.md @@ -0,0 +1,27 @@ +201\. Bitwise AND of Numbers Range + +Medium + +Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_. + +**Example 1:** + +**Input:** left = 5, right = 7 + +**Output:** 4 + +**Example 2:** + +**Input:** left = 0, right = 0 + +**Output:** 0 + +**Example 3:** + +**Input:** left = 1, right = 2147483647 + +**Output:** 0 + +**Constraints:** + +* 0 <= left <= right <= 231 - 1 diff --git a/src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.ts b/src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.ts new file mode 100644 index 0000000..04d02e0 --- /dev/null +++ b/src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.ts @@ -0,0 +1,18 @@ +// #Medium #Bit_Manipulation #Algorithm_II_Day_19_Bit_Manipulation +// #Top_Interview_150_Bit_Manipulation #2025_04_10_Time_2_ms_(99.12%)_Space_64.48_MB_(7.02%) + +function rangeBitwiseAnd(left: number, right: number): number { + const MASKS: number[] = [ + 0x00000000, 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, + 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, 0xffff8000, + 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, 0xffffff80, 0xffffffc0, + 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, + ] + if (left === right) { + return left + } + const leadingZeros = Math.clz32(left ^ right) + return right & MASKS[leadingZeros] +} + +export { rangeBitwiseAnd } diff --git a/src/main/ts/g0201_0300/s0202_happy_number/readme.md b/src/main/ts/g0201_0300/s0202_happy_number/readme.md new file mode 100644 index 0000000..6a56b07 --- /dev/null +++ b/src/main/ts/g0201_0300/s0202_happy_number/readme.md @@ -0,0 +1,39 @@ +202\. Happy Number + +Easy + +Write an algorithm to determine if a number `n` is happy. + +A **happy number** is a number defined by the following process: + +* Starting with any positive integer, replace the number by the sum of the squares of its digits. +* Repeat the process until the number equals 1 (where it will stay), or it **loops endlessly in a cycle** which does not include 1. +* Those numbers for which this process **ends in 1** are happy. + +Return `true` _if_ `n` _is a happy number, and_ `false` _if not_. + +**Example 1:** + +**Input:** n = 19 + +**Output:** true + +**Explanation:** + +12 + 92 = 82 + +82 + 22 = 68 + +62 + 82 = 100 + +12 + 02 + 02 = 1 + +**Example 2:** + +**Input:** n = 2 + +**Output:** false + +**Constraints:** + +* 1 <= n <= 231 - 1 \ No newline at end of file diff --git a/src/main/ts/g0201_0300/s0202_happy_number/solution.ts b/src/main/ts/g0201_0300/s0202_happy_number/solution.ts new file mode 100644 index 0000000..0e48c4d --- /dev/null +++ b/src/main/ts/g0201_0300/s0202_happy_number/solution.ts @@ -0,0 +1,23 @@ +// #Easy #Top_Interview_Questions #Hash_Table #Math #Two_Pointers #Algorithm_II_Day_21_Others +// #Programming_Skills_I_Day_4_Loop #Level_2_Day_1_Implementation/Simulation +// #Top_Interview_150_Hashmap #2025_04_10_Time_0_ms_(100.00%)_Space_55.45_MB_(83.98%) + +function isHappy(n: number): boolean { + let a = n + let rem: number + let sum = 0 + if (a === 1 || a === 7) { + return true + } else if (a > 1 && a < 10) { + return false + } else { + while (a !== 0) { + rem = a % 10 + sum += rem * rem + a = Math.floor(a / 10) + } + return sum === 1 ? true : isHappy(sum) + } +} + +export { isHappy } diff --git a/src/main/ts/g0201_0300/s0205_isomorphic_strings/readme.md b/src/main/ts/g0201_0300/s0205_isomorphic_strings/readme.md new file mode 100644 index 0000000..d91e8ce --- /dev/null +++ b/src/main/ts/g0201_0300/s0205_isomorphic_strings/readme.md @@ -0,0 +1,33 @@ +205\. Isomorphic Strings + +Easy + +Given two strings `s` and `t`, _determine if they are isomorphic_. + +Two strings `s` and `t` are isomorphic if the characters in `s` can be replaced to get `t`. + +All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself. + +**Example 1:** + +**Input:** s = "egg", t = "add" + +**Output:** true + +**Example 2:** + +**Input:** s = "foo", t = "bar" + +**Output:** false + +**Example 3:** + +**Input:** s = "paper", t = "title" + +**Output:** true + +**Constraints:** + +* 1 <= s.length <= 5 * 104 +* `t.length == s.length` +* `s` and `t` consist of any valid ascii character. diff --git a/src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts b/src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts new file mode 100644 index 0000000..cc73876 --- /dev/null +++ b/src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts @@ -0,0 +1,23 @@ +// #Easy #String #Hash_Table #Level_1_Day_2_String #Top_Interview_150_Hashmap +// #2025_04_10_Time_3_ms_(96.02%)_Space_56.62_MB_(65.86%) + +function isIsomorphic(s: string, t: string): boolean { + if (s.length !== t.length) { + return false + } + const mapS = new Map() + const mapT = new Map() + for (let i = 0; i < s.length; i++) { + if (mapS.has(s[i]) || mapT.has(t[i])) { + if (mapS.get(s[i]) !== t[i] || mapT.get(t[i]) !== s[i]) { + return false + } + } else { + mapS.set(s[i], t[i]) + mapT.set(t[i], s[i]) + } + } + return true +} + +export { isIsomorphic } diff --git a/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/readme.md b/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/readme.md new file mode 100644 index 0000000..0e301a6 --- /dev/null +++ b/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/readme.md @@ -0,0 +1,33 @@ +209\. Minimum Size Subarray Sum + +Medium + +Given an array of positive integers `nums` and a positive integer `target`, return the minimal length of a **contiguous subarray** [numsl, numsl+1, ..., numsr-1, numsr] of which the sum is greater than or equal to `target`. If there is no such subarray, return `0` instead. + +**Example 1:** + +**Input:** target = 7, nums = [2,3,1,2,4,3] + +**Output:** 2 + +**Explanation:** The subarray [4,3] has the minimal length under the problem constraint. + +**Example 2:** + +**Input:** target = 4, nums = [1,4,4] + +**Output:** 1 + +**Example 3:** + +**Input:** target = 11, nums = [1,1,1,1,1,1,1,1] + +**Output:** 0 + +**Constraints:** + +* 1 <= target <= 109 +* 1 <= nums.length <= 105 +* 1 <= nums[i] <= 105 + +**Follow up:** If you have figured out the `O(n)` solution, try coding another solution of which the time complexity is `O(n log(n))`. diff --git a/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts b/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts new file mode 100644 index 0000000..90c234f --- /dev/null +++ b/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts @@ -0,0 +1,29 @@ +// #Medium #Array #Binary_Search #Prefix_Sum #Sliding_Window #Algorithm_II_Day_5_Sliding_Window +// #Binary_Search_II_Day_1 #Top_Interview_150_Sliding_Window +// #2025_04_10_Time_2_ms_(88.11%)_Space_59.64_MB_(83.02%) + +function minSubArrayLen(target: number, nums: number[]): number { + let i = 0 + let j = 0 + let sum = 0 + let min = Number.MAX_SAFE_INTEGER + while (j < nums.length) { + sum += nums[j] + if (sum >= target) { + while (i <= j) { + if (sum - nums[i] >= target) { + sum -= nums[i] + i++ + } else { + break + } + } + min = Math.min(min, j - i + 1) + } + + j++ + } + return min === Number.MAX_SAFE_INTEGER ? 0 : min +} + +export { minSubArrayLen } diff --git a/src/test/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.test.ts b/src/test/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.test.ts new file mode 100644 index 0000000..bec5f07 --- /dev/null +++ b/src/test/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.test.ts @@ -0,0 +1,20 @@ +// tslint:disable:no-magic-numbers +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' +import { rightSideView } from 'src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution' +import { expect, test } from 'vitest' + +test('rightSideView', () => { + expect(rightSideView(createTreeNode([1, 2, 3, null, 5, null, 4]))).toEqual([1, 3, 4]) +}) + +test('rightSideView2', () => { + expect(rightSideView(createTreeNode([1, 2, 3, 4, null, null, null, 5]))).toEqual([1, 3, 4, 5]) +}) + +test('rightSideView3', () => { + expect(rightSideView(createTreeNode([1, null, 3]))).toEqual([1, 3]) +}) + +test('rightSideView4', () => { + expect(rightSideView(createTreeNode([]))).toEqual([]) +}) diff --git a/src/test/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.test.ts b/src/test/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.test.ts new file mode 100644 index 0000000..bcae1f9 --- /dev/null +++ b/src/test/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { rangeBitwiseAnd } from 'src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution' +import { expect, test } from 'vitest' + +test('rangeBitwiseAnd', () => { + expect(rangeBitwiseAnd(5, 7)).toEqual(4) +}) + +test('rangeBitwiseAnd2', () => { + expect(rangeBitwiseAnd(0, 0)).toEqual(0) +}) + +test('rangeBitwiseAnd3', () => { + expect(rangeBitwiseAnd(1, 2147483647)).toEqual(0) +}) diff --git a/src/test/ts/g0201_0300/s0202_happy_number/solution.test.ts b/src/test/ts/g0201_0300/s0202_happy_number/solution.test.ts new file mode 100644 index 0000000..71b00b9 --- /dev/null +++ b/src/test/ts/g0201_0300/s0202_happy_number/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { isHappy } from 'src/main/ts/g0201_0300/s0202_happy_number/solution' +import { expect, test } from 'vitest' + +test('isHappy', () => { + expect(isHappy(19)).toEqual(true) +}) + +test('isHappy2', () => { + expect(isHappy(2)).toEqual(false) +}) diff --git a/src/test/ts/g0201_0300/s0205_isomorphic_strings/solution.test.ts b/src/test/ts/g0201_0300/s0205_isomorphic_strings/solution.test.ts new file mode 100644 index 0000000..241b098 --- /dev/null +++ b/src/test/ts/g0201_0300/s0205_isomorphic_strings/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { isIsomorphic } from 'src/main/ts/g0201_0300/s0205_isomorphic_strings/solution' +import { expect, test } from 'vitest' + +test('isIsomorphic', () => { + expect(isIsomorphic('egg', 'add')).toEqual(true) +}) + +test('isIsomorphic2', () => { + expect(isIsomorphic('foo', 'bar')).toEqual(false) +}) + +test('isIsomorphic3', () => { + expect(isIsomorphic('paper', 'title')).toEqual(true) +}) diff --git a/src/test/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.test.ts b/src/test/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.test.ts new file mode 100644 index 0000000..24a92d0 --- /dev/null +++ b/src/test/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { minSubArrayLen } from 'src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution' +import { expect, test } from 'vitest' + +test('minSubArrayLen', () => { + expect(minSubArrayLen(7, [2,3,1,2,4,3])).toEqual(2) +}) + +test('minSubArrayLen2', () => { + expect(minSubArrayLen(4, [1,4,4])).toEqual(1) +}) + +test('minSubArrayLen3', () => { + expect(minSubArrayLen(11, [1,1,1,1,1,1,1,1])).toEqual(0) +}) From d10a54bf506cd9ff92069c607a6ca126e21e182e Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 11 Apr 2025 05:06:46 +0300 Subject: [PATCH 38/49] Improved tasks 173, 209 --- .../solution.ts | 34 +++++++++---------- .../solution.test.ts | 6 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts b/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts index 2454b58..077a102 100644 --- a/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts +++ b/src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts @@ -2,7 +2,7 @@ // #Data_Structure_II_Day_17_Tree #Programming_Skills_II_Day_16 #Level_2_Day_9_Binary_Search_Tree // #Top_Interview_150_Binary_Tree_General #2025_04_09_Time_6_ms_(98.16%)_Space_69.76_MB_(29.04%) -import { TreeNode } from "../../com_github_leetcode/treenode"; +import { TreeNode } from '../../com_github_leetcode/treenode' /** * Definition for a binary tree node. @@ -18,41 +18,41 @@ import { TreeNode } from "../../com_github_leetcode/treenode"; * } */ class BSTIterator { - private node: TreeNode | null; + private node: TreeNode | null constructor(root: TreeNode | null) { - this.node = root; + this.node = root } next(): number { - let res = -1; + let res = -1 while (this.node !== null) { if (this.node.left !== null) { - let rightMost = this.node.left; + let rightMost = this.node.left while (rightMost.right !== null && rightMost.right !== this.node) { - rightMost = rightMost.right; + rightMost = rightMost.right } if (rightMost.right === null) { - rightMost.right = this.node; - this.node = this.node.left; + rightMost.right = this.node + this.node = this.node.left } else { - rightMost.right = null; - res = this.node.val; - this.node = this.node.right; - return res; + rightMost.right = null + res = this.node.val + this.node = this.node.right + return res } } else { - res = this.node.val; - this.node = this.node.right; - return res; + res = this.node.val + this.node = this.node.right + return res } } - return res; + return res } hasNext(): boolean { - return this.node !== null; + return this.node !== null } } diff --git a/src/test/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.test.ts b/src/test/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.test.ts index 24a92d0..5ad38e7 100644 --- a/src/test/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.test.ts +++ b/src/test/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.test.ts @@ -3,13 +3,13 @@ import { minSubArrayLen } from 'src/main/ts/g0201_0300/s0209_minimum_size_subarr import { expect, test } from 'vitest' test('minSubArrayLen', () => { - expect(minSubArrayLen(7, [2,3,1,2,4,3])).toEqual(2) + expect(minSubArrayLen(7, [2, 3, 1, 2, 4, 3])).toEqual(2) }) test('minSubArrayLen2', () => { - expect(minSubArrayLen(4, [1,4,4])).toEqual(1) + expect(minSubArrayLen(4, [1, 4, 4])).toEqual(1) }) test('minSubArrayLen3', () => { - expect(minSubArrayLen(11, [1,1,1,1,1,1,1,1])).toEqual(0) + expect(minSubArrayLen(11, [1, 1, 1, 1, 1, 1, 1, 1])).toEqual(0) }) From 1717ca17b60da6ceaceb970f5725c3ef9c80ff1a Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Sat, 12 Apr 2025 18:34:59 +0700 Subject: [PATCH 39/49] Added tasks 210-222 --- README.md | 12 ++ .../s0210_course_schedule_ii/readme.md | 46 ++++++++ .../s0210_course_schedule_ii/solution.ts | 34 ++++++ .../readme.md | 39 +++++++ .../solution.ts | 57 ++++++++++ .../g0201_0300/s0212_word_search_ii/readme.md | 34 ++++++ .../s0212_word_search_ii/solution.ts | 104 ++++++++++++++++++ .../s0219_contains_duplicate_ii/readme.md | 29 +++++ .../s0219_contains_duplicate_ii/solution.ts | 18 +++ .../s0222_count_complete_tree_nodes/readme.md | 35 ++++++ .../solution.ts | 50 +++++++++ .../s0210_course_schedule_ii/solution.test.ts | 22 ++++ .../solution.test.ts | 14 +++ .../s0212_word_search_ii/solution.test.ts | 29 +++++ .../solution.test.ts | 15 +++ .../solution.test.ts | 16 +++ 16 files changed, 554 insertions(+) create mode 100644 src/main/ts/g0201_0300/s0210_course_schedule_ii/readme.md create mode 100644 src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts create mode 100644 src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/readme.md create mode 100644 src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts create mode 100644 src/main/ts/g0201_0300/s0212_word_search_ii/readme.md create mode 100644 src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts create mode 100644 src/main/ts/g0201_0300/s0219_contains_duplicate_ii/readme.md create mode 100644 src/main/ts/g0201_0300/s0219_contains_duplicate_ii/solution.ts create mode 100644 src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/readme.md create mode 100644 src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts create mode 100644 src/test/ts/g0201_0300/s0210_course_schedule_ii/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0212_word_search_ii/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0219_contains_duplicate_ii/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.test.ts diff --git a/README.md b/README.md index e72f8a0..25cfc2a 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0222 |[Count Complete Tree Nodes](src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree | 0 | 100.00 #### Day 11 @@ -801,6 +802,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0210 |[Course Schedule II](src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 2 | 99.76 #### Day 12 Dynamic Programming @@ -1088,6 +1090,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0202 |[Happy Number](src/main/ts/g0201_0300/s0202_happy_number/solution.ts)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 +| 0219 |[Contains Duplicate II](src/main/ts/g0201_0300/s0219_contains_duplicate_ii/solution.ts)| Easy | Array, Hash_Table, Sliding_Window | 17 | 79.29 | 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 34 | 90.07 #### Top Interview 150 Intervals @@ -1137,6 +1140,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0129 |[Sum Root to Leaf Numbers](src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0173 |[Binary Search Tree Iterator](src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 6 | 98.16 +| 0222 |[Count Complete Tree Nodes](src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree | 0 | 100.00 | 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 #### Top Interview 150 Binary Tree BFS @@ -1160,6 +1164,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 | 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 +| 0210 |[Course Schedule II](src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 2 | 99.76 #### Top Interview 150 Graph BFS @@ -1172,6 +1177,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 +| 0211 |[Design Add and Search Words Data Structure](src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts)| Medium | String, Depth_First_Search, Design, Trie | 450 | 92.88 +| 0212 |[Word Search II](src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie | ew 150 | ew 150 Trie #### Top Interview 150 Backtracking @@ -1741,8 +1748,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Level_2_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 3 | 92.85 | 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_II_Day_17_Tree, Level_2_Day_9_Binary_Search_Tree, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Level_2_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0222 |[Count Complete Tree Nodes](src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree, Binary_Search_II_Day_10, Top_Interview_150_Binary_Tree_General | 0 | 100.00 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 +| 0219 |[Contains Duplicate II](src/main/ts/g0201_0300/s0219_contains_duplicate_ii/solution.ts)| Easy | Array, Hash_Table, Sliding_Window, Top_Interview_150_Hashmap | 17 | 79.29 | 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Data_Structure_II_Day_20_Heap_Priority_Queue, Top_Interview_150_Heap, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 +| 0212 |[Word Search II](src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie | ew 150 | ew 150 Trie +| 0211 |[Design Add and Search Words Data Structure](src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts)| Medium | String, Depth_First_Search, Design, Trie, Top_Interview_150_Trie | 450 | 92.88 +| 0210 |[Course Schedule II](src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Level_2_Day_11_Graph/BFS/DFS, Top_Interview_150_Graph_General | 2 | 99.76 | 0209 |[Minimum Size Subarray Sum](src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Binary_Search_II_Day_1, Top_Interview_150_Sliding_Window | 2 | 88.11 | 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Level_2_Day_16_Design, Udemy_Trie_and_Heap, Top_Interview_150_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 | 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Top_Interview_150_Graph_General, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 diff --git a/src/main/ts/g0201_0300/s0210_course_schedule_ii/readme.md b/src/main/ts/g0201_0300/s0210_course_schedule_ii/readme.md new file mode 100644 index 0000000..5a1b0cb --- /dev/null +++ b/src/main/ts/g0201_0300/s0210_course_schedule_ii/readme.md @@ -0,0 +1,46 @@ +210\. Course Schedule II + +Medium + +There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where prerequisites[i] = [ai, bi] indicates that you **must** take course bi first if you want to take course ai. + +* For example, the pair `[0, 1]`, indicates that to take course `0` you have to first take course `1`. + +Return _the ordering of courses you should take to finish all courses_. If there are many valid answers, return **any** of them. If it is impossible to finish all courses, return **an empty array**. + +**Example 1:** + +**Input:** numCourses = 2, prerequisites = [[1,0]] + +**Output:** [0,1] + +**Explanation:** + + There are a total of 2 courses to take. To take course 1 you should have finished course 0. + So the correct course order is [0,1]. + +**Example 2:** + +**Input:** numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]] + +**Output:** [0,2,1,3] + +**Explanation:** + + There are a total of 4 courses to take. To take course 3 you should have finished both courses 1 and 2. Both courses 1 and 2 should be taken after you finished course 0. + So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3]. + +**Example 3:** + +**Input:** numCourses = 1, prerequisites = [] + +**Output:** [0] + +**Constraints:** + +* `1 <= numCourses <= 2000` +* `0 <= prerequisites.length <= numCourses * (numCourses - 1)` +* `prerequisites[i].length == 2` +* 0 <= ai, bi < numCourses +* ai != bi +* All the pairs [ai, bi] are **distinct**. diff --git a/src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts b/src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts new file mode 100644 index 0000000..1d77c43 --- /dev/null +++ b/src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts @@ -0,0 +1,34 @@ +// #Medium #Top_Interview_Questions #Depth_First_Search #Breadth_First_Search #Graph +// #Topological_Sort #Level_2_Day_11_Graph/BFS/DFS #Top_Interview_150_Graph_General +// #2025_04_12_Time_2_ms_(99.76%)_Space_58.61_MB_(86.54%) + +function findOrder(numCourses: number, prerequisites: number[][]): number[] { + let sortedOrder: number[] = [] + if (numCourses < 0) return sortedOrder + let inDegree = new Array(numCourses).fill(0), + graph = new Array(numCourses).fill(0).map(() => new Array()), + source = new Array() + prerequisites.forEach((course: number[]) => { + graph[course[1]].push(course[0]) + inDegree[course[0]]++ + }) + inDegree.forEach((value: number, index: number) => { + if (value === 0) { + source.push(index) + } + }) + while (source.length > 0) { + const course = source.shift() + if (course === undefined) break + sortedOrder.push(course) + graph[course].forEach((val) => { + inDegree[val]-- + if (inDegree[val] === 0) { + source.push(val) + } + }) + } + return sortedOrder.length === numCourses ? sortedOrder : [] +} + +export { findOrder } diff --git a/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/readme.md b/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/readme.md new file mode 100644 index 0000000..940cb2f --- /dev/null +++ b/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/readme.md @@ -0,0 +1,39 @@ +211\. Design Add and Search Words Data Structure + +Medium + +Design a data structure that supports adding new words and finding if a string matches any previously added string. + +Implement the `WordDictionary` class: + +* `WordDictionary()` Initializes the object. +* `void addWord(word)` Adds `word` to the data structure, it can be matched later. +* `bool search(word)` Returns `true` if there is any string in the data structure that matches `word` or `false` otherwise. `word` may contain dots `'.'` where dots can be matched with any letter. + +**Example:** + +**Input** + + ["WordDictionary","addWord","addWord","addWord","search","search","search","search"] [[],["bad"],["dad"],["mad"],["pad"],["bad"],[".ad"],["b.."]] + +**Output** + + [null,null,null,null,false,true,true,true] + +**Explanation** + + WordDictionary wordDictionary = new WordDictionary(); + wordDictionary.addWord("bad"); + wordDictionary.addWord("dad"); + wordDictionary.addWord("mad"); + wordDictionary.search("pad"); // return False + wordDictionary.search("bad"); // return True + wordDictionary.search(".ad"); // return True + wordDictionary.search("b.."); // return True + +**Constraints:** + +* `1 <= word.length <= 500` +* `word` in `addWord` consists lower-case English letters. +* `word` in `search` consist of `'.'` or lower-case English letters. +* At most `50000` calls will be made to `addWord` and `search`. diff --git a/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts b/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts new file mode 100644 index 0000000..cfa6011 --- /dev/null +++ b/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts @@ -0,0 +1,57 @@ +// #Medium #String #Depth_First_Search #Design #Trie #Top_Interview_150_Trie +// #2025_04_12_Time_450_ms_(92.88%)_Space_92.76_MB_(88.14%) + +interface TrieNode { + [key: string]: TrieNode | boolean +} + +class WordDictionary { + root: TrieNode + + constructor() { + this.root = {} + } + + addWord(word: string): void { + let current = this.root + for (let i = 0; i < word.length; i++) { + const letter = word[i] + if (!current.hasOwnProperty(letter)) { + current[letter] = {} + } + current = current[letter] as TrieNode + } + current.end = true + } + + search(word: string): boolean { + const searchSubtree = (word: string, index: number, subtree: TrieNode) => { + if (word.length === index) { + return subtree.hasOwnProperty('end') + } + const currentLetter = word[index] + index += 1 + + if (currentLetter === '.') { + return Object.keys(subtree).some((letter) => searchSubtree(word, index, subtree[letter] as TrieNode)) + } else { + if (subtree.hasOwnProperty(currentLetter)) { + return searchSubtree(word, index, subtree[currentLetter] as TrieNode) + } else { + return false + } + } + } + + return searchSubtree(word, 0, this.root) + } +} + +/** + * Your WordDictionary object will be instantiated and called as such: + * var obj = new WordDictionary() + * obj.addWord(word) + * var param_2 = obj.search(word) + */ + +export { WordDictionary } diff --git a/src/main/ts/g0201_0300/s0212_word_search_ii/readme.md b/src/main/ts/g0201_0300/s0212_word_search_ii/readme.md new file mode 100644 index 0000000..f6e6f9d --- /dev/null +++ b/src/main/ts/g0201_0300/s0212_word_search_ii/readme.md @@ -0,0 +1,34 @@ +212\. Word Search II + +Hard + +Given an `m x n` `board` of characters and a list of strings `words`, return _all words on the board_. + +Each word must be constructed from letters of sequentially adjacent cells, where **adjacent cells** are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/11/07/search1.jpg) + +**Input:** board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]], words = ["oath","pea","eat","rain"] + +**Output:** ["eat","oath"] + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2020/11/07/search2.jpg) + +**Input:** board = [["a","b"],["c","d"]], words = ["abcb"] + +**Output:** [] + +**Constraints:** + +* `m == board.length` +* `n == board[i].length` +* `1 <= m, n <= 12` +* `board[i][j]` is a lowercase English letter. +* 1 <= words.length <= 3 * 104 +* `1 <= words[i].length <= 10` +* `words[i]` consists of lowercase English letters. +* All the strings of `words` are unique. diff --git a/src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts b/src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts new file mode 100644 index 0000000..4fd1dc5 --- /dev/null +++ b/src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts @@ -0,0 +1,104 @@ +// #Hard #Top_Interview_Questions #Array #String #Matrix #Backtracking #Trie #Top_Interview_150_Trie +// #2025_04_12_Time_62_ms_(99.46%)_Space_60.47_MB_(72.83%) + +class Tree { + children: Map + end: string | null + + constructor() { + this.children = new Map() + this.end = null + } + + static addWord(node: Tree, word: string): void { + let cur = node + for (const char of word) { + if (!cur.children.has(char)) { + cur.children.set(char, new Tree()) + } + cur = cur.children.get(char)! + } + cur.end = word + } + + static deleteWord(node: Tree, word: string): void { + const stack: [Tree, string][] = [] + let cur = node + for (const char of word) { + const next = cur.children.get(char) + if (!next) return + stack.push([cur, char]) + cur = next + } + cur.end = null + for (let i = stack.length - 1; i >= 0; i--) { + const [parent, char] = stack[i] + const child = parent.children.get(char)! + if (child.children.size === 0 && child.end === null) { + parent.children.delete(char) + } else { + break + } + } + } + + getChild(char: string): Tree | null { + return this.children.get(char) || null + } + + len(): number { + return this.children.size + } +} + +function findWords(board: string[][], words: string[]): string[] { + if (board.length === 0 || board[0].length === 0) { + return [] + } + const root = new Tree() + for (const word of words) { + Tree.addWord(root, word) + } + const collected: string[] = [] + for (let i = 0; i < board.length; i++) { + for (let j = 0; j < board[0].length; j++) { + dfs(board, i, j, root, collected, root) + } + } + return collected +} + +function dfs(board: string[][], i: number, j: number, cur: Tree, collected: string[], root: Tree): void { + const c = board[i][j] + if (c === '-') { + return + } + const next = cur.getChild(c) + if (!next) { + return + } + if (next.end !== null) { + collected.push(next.end) + const word = next.end + next.end = null + if (next.len() === 0) { + Tree.deleteWord(root, word) + } + } + board[i][j] = '-' + if (i > 0) { + dfs(board, i - 1, j, next, collected, root) + } + if (i + 1 < board.length) { + dfs(board, i + 1, j, next, collected, root) + } + if (j > 0) { + dfs(board, i, j - 1, next, collected, root) + } + if (j + 1 < board[0].length) { + dfs(board, i, j + 1, next, collected, root) + } + board[i][j] = c +} + +export { findWords } diff --git a/src/main/ts/g0201_0300/s0219_contains_duplicate_ii/readme.md b/src/main/ts/g0201_0300/s0219_contains_duplicate_ii/readme.md new file mode 100644 index 0000000..41bd3ac --- /dev/null +++ b/src/main/ts/g0201_0300/s0219_contains_duplicate_ii/readme.md @@ -0,0 +1,29 @@ +219\. Contains Duplicate II + +Easy + +Given an integer array `nums` and an integer `k`, return `true` if there are two **distinct indices** `i` and `j` in the array such that `nums[i] == nums[j]` and `abs(i - j) <= k`. + +**Example 1:** + +**Input:** nums = [1,2,3,1], k = 3 + +**Output:** true + +**Example 2:** + +**Input:** nums = [1,0,1,1], k = 1 + +**Output:** true + +**Example 3:** + +**Input:** nums = [1,2,3,1,2,3], k = 2 + +**Output:** false + +**Constraints:** + +* 1 <= nums.length <= 105 +* -109 <= nums[i] <= 109 +* 0 <= k <= 105 diff --git a/src/main/ts/g0201_0300/s0219_contains_duplicate_ii/solution.ts b/src/main/ts/g0201_0300/s0219_contains_duplicate_ii/solution.ts new file mode 100644 index 0000000..5ac8948 --- /dev/null +++ b/src/main/ts/g0201_0300/s0219_contains_duplicate_ii/solution.ts @@ -0,0 +1,18 @@ +// #Easy #Array #Hash_Table #Sliding_Window #Top_Interview_150_Hashmap +// #2025_04_12_Time_17_ms_(79.29%)_Space_70.85_MB_(72.75%) + +function containsNearbyDuplicate(nums: number[], k: number): boolean { + const s = new Set() + for (let i = 0, l = nums.length; i < l; i++) { + if (i > k) { + s.delete(nums[i - k - 1]) + } + if (s.has(nums[i])) { + return true + } + s.add(nums[i]) + } + return false +} + +export { containsNearbyDuplicate } diff --git a/src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/readme.md b/src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/readme.md new file mode 100644 index 0000000..07e88f8 --- /dev/null +++ b/src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/readme.md @@ -0,0 +1,35 @@ +222\. Count Complete Tree Nodes + +Medium + +Given the `root` of a **complete** binary tree, return the number of the nodes in the tree. + +According to **[Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees)**, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far left as possible. It can have between `1` and 2h nodes inclusive at the last level `h`. + +Design an algorithm that runs in less than `O(n)` time complexity. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/01/14/complete.jpg) + +**Input:** root = [1,2,3,4,5,6] + +**Output:** 6 + +**Example 2:** + +**Input:** root = [] + +**Output:** 0 + +**Example 3:** + +**Input:** root = [1] + +**Output:** 1 + +**Constraints:** + +* The number of nodes in the tree is in the range [0, 5 * 104]. +* 0 <= Node.val <= 5 * 104 +* The tree is guaranteed to be **complete**. diff --git a/src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts b/src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts new file mode 100644 index 0000000..60f5c7e --- /dev/null +++ b/src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts @@ -0,0 +1,50 @@ +// #Easy #Depth_First_Search #Tree #Binary_Search #Binary_Tree #Binary_Search_II_Day_10 +// #Top_Interview_150_Binary_Tree_General #2025_04_12_Time_0_ms_(100.00%)_Space_75.06_MB_(64.02%) + +import { TreeNode } from '../../com_github_leetcode/treenode' + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +function countNodes(root: TreeNode | null): number { + if (root === null) { + return 0 + } + const leftHeight = getLeftHeight(root) + const rightHeight = getRightHeight(root) + if (leftHeight === rightHeight) { + return (1 << leftHeight) - 1 + } else { + return 1 + countNodes(root.left) + countNodes(root.right) + } +} + +function getLeftHeight(node: TreeNode | null): number { + let height = 0 + while (node !== null) { + height++ + node = node.left + } + return height +} + +function getRightHeight(node: TreeNode | null): number { + let height = 0 + while (node !== null) { + height++ + node = node.right + } + return height +} + +export { countNodes } diff --git a/src/test/ts/g0201_0300/s0210_course_schedule_ii/solution.test.ts b/src/test/ts/g0201_0300/s0210_course_schedule_ii/solution.test.ts new file mode 100644 index 0000000..193e5bc --- /dev/null +++ b/src/test/ts/g0201_0300/s0210_course_schedule_ii/solution.test.ts @@ -0,0 +1,22 @@ +// tslint:disable:no-magic-numbers +import { findOrder } from 'src/main/ts/g0201_0300/s0210_course_schedule_ii/solution' +import { expect, test } from 'vitest' + +test('findOrder', () => { + expect(findOrder(2, [[1, 0]])).toEqual([0, 1]) +}) + +test('findOrder2', () => { + expect( + findOrder(4, [ + [1, 0], + [2, 0], + [3, 1], + [3, 2], + ]), + ).toEqual([0, 1, 2, 3]) +}) + +test('findOrder2', () => { + expect(findOrder(1, [])).toEqual([0]) +}) diff --git a/src/test/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.test.ts b/src/test/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.test.ts new file mode 100644 index 0000000..0341658 --- /dev/null +++ b/src/test/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.test.ts @@ -0,0 +1,14 @@ +// tslint:disable:no-magic-numbers +import { WordDictionary } from 'src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution' +import { expect, test } from 'vitest' + +test('wordDictionary', () => { + const wordDictionary = new WordDictionary() + wordDictionary.addWord('bad') + wordDictionary.addWord('dad') + wordDictionary.addWord('mad') + expect(wordDictionary.search('pad')).toBeFalsy() + expect(wordDictionary.search('bad')).toBeTruthy() + expect(wordDictionary.search('.ad')).toBeTruthy() + expect(wordDictionary.search('b..')).toBeTruthy() +}) diff --git a/src/test/ts/g0201_0300/s0212_word_search_ii/solution.test.ts b/src/test/ts/g0201_0300/s0212_word_search_ii/solution.test.ts new file mode 100644 index 0000000..c669386 --- /dev/null +++ b/src/test/ts/g0201_0300/s0212_word_search_ii/solution.test.ts @@ -0,0 +1,29 @@ +// tslint:disable:no-magic-numbers +import { findWords } from 'src/main/ts/g0201_0300/s0212_word_search_ii/solution' +import { expect, test } from 'vitest' + +test('findWords', () => { + expect( + findWords( + [ + ['o', 'a', 'a', 'n'], + ['e', 't', 'a', 'e'], + ['i', 'h', 'k', 'r'], + ['i', 'f', 'l', 'v'], + ], + ['oath', 'pea', 'eat', 'rain'], + ), + ).toEqual(['oath', 'eat']) +}) + +test('findWords2', () => { + expect( + findWords( + [ + ['a', 'b'], + ['c', 'd'], + ], + ['abcb'], + ), + ).toEqual([]) +}) diff --git a/src/test/ts/g0201_0300/s0219_contains_duplicate_ii/solution.test.ts b/src/test/ts/g0201_0300/s0219_contains_duplicate_ii/solution.test.ts new file mode 100644 index 0000000..6614546 --- /dev/null +++ b/src/test/ts/g0201_0300/s0219_contains_duplicate_ii/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { containsNearbyDuplicate } from 'src/main/ts/g0201_0300/s0219_contains_duplicate_ii/solution' +import { expect, test } from 'vitest' + +test('containsNearbyDuplicate', () => { + expect(containsNearbyDuplicate([1, 2, 3, 1], 3)).toEqual(true) +}) + +test('containsNearbyDuplicate2', () => { + expect(containsNearbyDuplicate([1, 0, 1, 1], 1)).toEqual(true) +}) + +test('containsNearbyDuplicate3', () => { + expect(containsNearbyDuplicate([1, 2, 3, 1, 2, 3], 2)).toEqual(false) +}) diff --git a/src/test/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.test.ts b/src/test/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.test.ts new file mode 100644 index 0000000..65eb6d8 --- /dev/null +++ b/src/test/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.test.ts @@ -0,0 +1,16 @@ +// tslint:disable:no-magic-numbers +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' +import { countNodes } from 'src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution' +import { expect, test } from 'vitest' + +test('countNodes', () => { + expect(countNodes(createTreeNode([1, 2, 3, 4, 5, 6]))).toEqual(6) +}) + +test('countNodes2', () => { + expect(countNodes(createTreeNode([]))).toEqual(0) +}) + +test('countNodes3', () => { + expect(countNodes(createTreeNode([1]))).toEqual(1) +}) From 5a466ca0f8185cc50471a4a00ec0096e20908330 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Sat, 12 Apr 2025 22:18:42 +0700 Subject: [PATCH 40/49] Added tasks 224-290 --- README.md | 18 ++++++- .../s0224_basic_calculator/readme.md | 35 ++++++++++++ .../s0224_basic_calculator/solution.ts | 39 ++++++++++++++ .../g0201_0300/s0228_summary_ranges/readme.md | 53 +++++++++++++++++++ .../s0228_summary_ranges/solution.ts | 34 ++++++++++++ .../g0201_0300/s0242_valid_anagram/readme.md | 24 +++++++++ .../s0242_valid_anagram/solution.ts | 17 ++++++ .../g0201_0300/s0289_game_of_life/readme.md | 42 +++++++++++++++ .../g0201_0300/s0289_game_of_life/solution.ts | 40 ++++++++++++++ .../g0201_0300/s0290_word_pattern/readme.md | 40 ++++++++++++++ .../g0201_0300/s0290_word_pattern/solution.ts | 27 ++++++++++ .../s0224_basic_calculator/solution.test.ts | 15 ++++++ .../s0228_summary_ranges/solution.test.ts | 11 ++++ .../s0242_valid_anagram/solution.test.ts | 11 ++++ .../s0289_game_of_life/solution.test.ts | 31 +++++++++++ .../s0290_word_pattern/solution.test.ts | 15 ++++++ 16 files changed, 450 insertions(+), 2 deletions(-) create mode 100644 src/main/ts/g0201_0300/s0224_basic_calculator/readme.md create mode 100644 src/main/ts/g0201_0300/s0224_basic_calculator/solution.ts create mode 100644 src/main/ts/g0201_0300/s0228_summary_ranges/readme.md create mode 100644 src/main/ts/g0201_0300/s0228_summary_ranges/solution.ts create mode 100644 src/main/ts/g0201_0300/s0242_valid_anagram/readme.md create mode 100644 src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts create mode 100644 src/main/ts/g0201_0300/s0289_game_of_life/readme.md create mode 100644 src/main/ts/g0201_0300/s0289_game_of_life/solution.ts create mode 100644 src/main/ts/g0201_0300/s0290_word_pattern/readme.md create mode 100644 src/main/ts/g0201_0300/s0290_word_pattern/solution.ts create mode 100644 src/test/ts/g0201_0300/s0224_basic_calculator/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0228_summary_ranges/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0242_valid_anagram/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0289_game_of_life/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0290_word_pattern/solution.test.ts diff --git a/README.md b/README.md index 25cfc2a..7a7fb31 100644 --- a/README.md +++ b/README.md @@ -393,6 +393,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting | 4 | 97.99 #### Day 12 Class and Object @@ -884,6 +885,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 | 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting | 4 | 97.99 | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 | 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers | 0 | 100.00 @@ -1081,12 +1083,15 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0054 |[Spiral Matrix](src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 | 0048 |[Rotate Image](src/main/ts/g0001_0100/s0048_rotate_image/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 | 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 4 | 50.63 +| 0289 |[Game of Life](src/main/ts/g0201_0300/s0289_game_of_life/solution.ts)| Medium | Array, Matrix, Simulation | 0 | 100.00 #### Top Interview 150 Hashmap | | | | | | |-|-|-|-|-|- | 0205 |[Isomorphic Strings](src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts)| Easy | String, Hash_Table | 3 | 96.02 +| 0290 |[Word Pattern](src/main/ts/g0201_0300/s0290_word_pattern/solution.ts)| Easy | String, Hash_Table | 0 | 100.00 +| 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting | 4 | 97.99 | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0202 |[Happy Number](src/main/ts/g0201_0300/s0202_happy_number/solution.ts)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 @@ -1097,6 +1102,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0228 |[Summary Ranges](src/main/ts/g0201_0300/s0228_summary_ranges/solution.ts)| Easy | Array | 0 | 100.00 | 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 | 0057 |[Insert Interval](src/main/ts/g0001_0100/s0057_insert_interval/solution.ts)| Medium | Array | 0 | 100.00 @@ -1108,6 +1114,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0071 |[Simplify Path](src/main/ts/g0001_0100/s0071_simplify_path/solution.ts)| Medium | String, Stack | 0 | 100.00 | 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 | 0150 |[Evaluate Reverse Polish Notation](src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts)| Medium | Top_Interview_Questions, Array, Math, Stack | 1 | 97.48 +| 0224 |[Basic Calculator](src/main/ts/g0201_0300/s0224_basic_calculator/solution.ts)| Hard | String, Math, Stack, Recursion | 6 | 96.62 #### Top Interview 150 Linked List @@ -1178,7 +1185,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 | 0211 |[Design Add and Search Words Data Structure](src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts)| Medium | String, Depth_First_Search, Design, Trie | 450 | 92.88 -| 0212 |[Word Search II](src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie | ew 150 | ew 150 Trie +| 0212 |[Word Search II](src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie | 62 | 99.46 #### Top Interview 150 Backtracking @@ -1308,6 +1315,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting | 4 | 97.99 #### Day 7 Linked List @@ -1405,6 +1413,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0290 |[Word Pattern](src/main/ts/g0201_0300/s0290_word_pattern/solution.ts)| Easy | String, Hash_Table | 0 | 100.00 | 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 4 | 86.89 #### Day 8 String @@ -1739,20 +1748,25 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_20, Level_2_Day_12_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 | 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Algorithm_II_Day_16_Dynamic_Programming, Binary_Search_II_Day_3, Dynamic_Programming_I_Day_18, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 | 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Top_Interview_150_Heap, Big_O_Time_O(n\*log_n)_Space_O(n) | 106 | 92.31 +| 0290 |[Word Pattern](src/main/ts/g0201_0300/s0290_word_pattern/solution.ts)| Easy | String, Hash_Table, Data_Structure_II_Day_7_String, Top_Interview_150_Hashmap | 0 | 100.00 +| 0289 |[Game of Life](src/main/ts/g0201_0300/s0289_game_of_life/solution.ts)| Medium | Array, Matrix, Simulation, Top_Interview_150_Matrix | 0 | 100.00 | 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Binary_Search_II_Day_5, Big_O_Time_O(n)_Space_O(n) | 5 | 88.65 | 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Programming_Skills_I_Day_6_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 +| 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting, Data_Structure_I_Day_6_String, Programming_Skills_I_Day_11_Containers_and_Libraries, Udemy_Strings, Top_Interview_150_Hashmap | 4 | 97.99 | 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Data_Structure_II_Day_4_Array, Binary_Search_II_Day_8, Big_O_Time_O(n+m)_Space_O(1) | 42 | 94.61 | 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Udemy_Arrays, Big_O_Time_O(n\*k)_Space_O(n+k) | 26 | 99.07 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Data_Structure_II_Day_5_Array, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 | 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_18_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 | 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Level_2_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 3 | 92.85 | 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_II_Day_17_Tree, Level_2_Day_9_Binary_Search_Tree, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0228 |[Summary Ranges](src/main/ts/g0201_0300/s0228_summary_ranges/solution.ts)| Easy | Array, Top_Interview_150_Intervals | 0 | 100.00 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_12_Tree, Level_2_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0224 |[Basic Calculator](src/main/ts/g0201_0300/s0224_basic_calculator/solution.ts)| Hard | String, Math, Stack, Recursion, Top_Interview_150_Stack | 6 | 96.62 | 0222 |[Count Complete Tree Nodes](src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree, Binary_Search_II_Day_10, Top_Interview_150_Binary_Tree_General | 0 | 100.00 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 | 0219 |[Contains Duplicate II](src/main/ts/g0201_0300/s0219_contains_duplicate_ii/solution.ts)| Easy | Array, Hash_Table, Sliding_Window, Top_Interview_150_Hashmap | 17 | 79.29 | 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Data_Structure_II_Day_20_Heap_Priority_Queue, Top_Interview_150_Heap, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 -| 0212 |[Word Search II](src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie | ew 150 | ew 150 Trie +| 0212 |[Word Search II](src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie, Top_Interview_150_Trie | 62 | 99.46 | 0211 |[Design Add and Search Words Data Structure](src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts)| Medium | String, Depth_First_Search, Design, Trie, Top_Interview_150_Trie | 450 | 92.88 | 0210 |[Course Schedule II](src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Level_2_Day_11_Graph/BFS/DFS, Top_Interview_150_Graph_General | 2 | 99.76 | 0209 |[Minimum Size Subarray Sum](src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Binary_Search_II_Day_1, Top_Interview_150_Sliding_Window | 2 | 88.11 diff --git a/src/main/ts/g0201_0300/s0224_basic_calculator/readme.md b/src/main/ts/g0201_0300/s0224_basic_calculator/readme.md new file mode 100644 index 0000000..fc89eda --- /dev/null +++ b/src/main/ts/g0201_0300/s0224_basic_calculator/readme.md @@ -0,0 +1,35 @@ +224\. Basic Calculator + +Hard + +Given a string `s` representing a valid expression, implement a basic calculator to evaluate it, and return _the result of the evaluation_. + +**Note:** You are **not** allowed to use any built-in function which evaluates strings as mathematical expressions, such as `eval()`. + +**Example 1:** + +**Input:** s = "1 + 1" + +**Output:** 2 + +**Example 2:** + +**Input:** s = " 2-1 + 2 " + +**Output:** 3 + +**Example 3:** + +**Input:** s = "(1+(4+5+2)-3)+(6+8)" + +**Output:** 23 + +**Constraints:** + +* 1 <= s.length <= 3 * 105 +* `s` consists of digits, `'+'`, `'-'`, `'('`, `')'`, and `' '`. +* `s` represents a valid expression. +* `'+'` is **not** used as a unary operation (i.e., `"+1"` and `"+(2 + 3)"` is invalid). +* `'-'` could be used as a unary operation (i.e., `"-1"` and `"-(2 + 3)"` is valid). +* There will be no two consecutive operators in the input. +* Every number and running calculation will fit in a signed 32-bit integer. diff --git a/src/main/ts/g0201_0300/s0224_basic_calculator/solution.ts b/src/main/ts/g0201_0300/s0224_basic_calculator/solution.ts new file mode 100644 index 0000000..811c88f --- /dev/null +++ b/src/main/ts/g0201_0300/s0224_basic_calculator/solution.ts @@ -0,0 +1,39 @@ +// #Hard #String #Math #Stack #Recursion #Top_Interview_150_Stack +// #2025_04_12_Time_6_ms_(96.62%)_Space_57.57_MB_(89.85%) + +function calculate(s: string): number { + let i = 0 + + function helper(ca: string[]): number { + let num = 0 + let prenum = 0 + let isPlus = true + while (i < ca.length) { + const c = ca[i] + if (c !== ' ') { + if (c >= '0' && c <= '9') { + num = num * 10 + parseInt(c) + } else if (c === '+') { + prenum += num * (isPlus ? 1 : -1) + isPlus = true + num = 0 + } else if (c === '-') { + prenum += num * (isPlus ? 1 : -1) + isPlus = false + num = 0 + } else if (c === '(') { + i++ + num = helper(ca) + } else if (c === ')') { + prenum += num * (isPlus ? 1 : -1) + return prenum + } + } + i++ + } + return prenum + num * (isPlus ? 1 : -1) + } + return helper(s.split('')) +} + +export { calculate } diff --git a/src/main/ts/g0201_0300/s0228_summary_ranges/readme.md b/src/main/ts/g0201_0300/s0228_summary_ranges/readme.md new file mode 100644 index 0000000..e8593fb --- /dev/null +++ b/src/main/ts/g0201_0300/s0228_summary_ranges/readme.md @@ -0,0 +1,53 @@ +228\. Summary Ranges + +Easy + +You are given a **sorted unique** integer array `nums`. + +Return _the **smallest sorted** list of ranges that **cover all the numbers in the array exactly**_. That is, each element of `nums` is covered by exactly one of the ranges, and there is no integer `x` such that `x` is in one of the ranges but not in `nums`. + +Each range `[a,b]` in the list should be output as: + +* `"a->b"` if `a != b` +* `"a"` if `a == b` + +**Example 1:** + +**Input:** nums = [0,1,2,4,5,7] + +**Output:** ["0->2","4->5","7"] + +**Explanation:** The ranges are: [0,2] --> "0->2" [4,5] --> "4->5" [7,7] --> "7" + +**Example 2:** + +**Input:** nums = [0,2,3,4,6,8,9] + +**Output:** ["0","2->4","6","8->9"] + +**Explanation:** The ranges are: [0,0] --> "0" [2,4] --> "2->4" [6,6] --> "6" [8,9] --> "8->9" + +**Example 3:** + +**Input:** nums = [] + +**Output:** [] + +**Example 4:** + +**Input:** nums = [-1] + +**Output:** ["-1"] + +**Example 5:** + +**Input:** nums = [0] + +**Output:** ["0"] + +**Constraints:** + +* `0 <= nums.length <= 20` +* -231 <= nums[i] <= 231 - 1 +* All the values of `nums` are **unique**. +* `nums` is sorted in ascending order. diff --git a/src/main/ts/g0201_0300/s0228_summary_ranges/solution.ts b/src/main/ts/g0201_0300/s0228_summary_ranges/solution.ts new file mode 100644 index 0000000..347c551 --- /dev/null +++ b/src/main/ts/g0201_0300/s0228_summary_ranges/solution.ts @@ -0,0 +1,34 @@ +// #Easy #Array #Top_Interview_150_Intervals #2025_04_12_Time_0_ms_(100.00%)_Space_55.25_MB_(57.62%) + +function summaryRanges(nums: number[]): string[] { + const ranges: string[] = [] + const n = nums.length + if (n === 0) { + return ranges + } + let a = nums[0] + let b = a + let strB = '' + for (let i = 1; i < n; i++) { + if (nums[i] !== b + 1) { + strB = a.toString() + if (a !== b) { + strB += '->' + b.toString() + } + ranges.push(strB) + a = nums[i] + b = a + strB = '' + } else { + b++ + } + } + strB = a.toString() + if (a !== b) { + strB += '->' + b.toString() + } + ranges.push(strB) + return ranges +} + +export { summaryRanges } diff --git a/src/main/ts/g0201_0300/s0242_valid_anagram/readme.md b/src/main/ts/g0201_0300/s0242_valid_anagram/readme.md new file mode 100644 index 0000000..417acc0 --- /dev/null +++ b/src/main/ts/g0201_0300/s0242_valid_anagram/readme.md @@ -0,0 +1,24 @@ +242\. Valid Anagram + +Easy + +Given two strings `s` and `t`, return `true` _if_ `t` _is an anagram of_ `s`_, and_ `false` _otherwise_. + +**Example 1:** + +**Input:** s = "anagram", t = "nagaram" + +**Output:** true + +**Example 2:** + +**Input:** s = "rat", t = "car" + +**Output:** false + +**Constraints:** + +* 1 <= s.length, t.length <= 5 * 104 +* `s` and `t` consist of lowercase English letters. + +**Follow up:** What if the inputs contain Unicode characters? How would you adapt your solution to such a case? diff --git a/src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts b/src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts new file mode 100644 index 0000000..936a93e --- /dev/null +++ b/src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts @@ -0,0 +1,17 @@ +// #Easy #String #Hash_Table #Sorting #Data_Structure_I_Day_6_String +// #Programming_Skills_I_Day_11_Containers_and_Libraries #Udemy_Strings #Top_Interview_150_Hashmap +// #2025_04_12_Time_4_ms_(97.99%)_Space_57.08_MB_(80.13%) + +function isAnagram(s: string, t: string): boolean { + if (s.length !== t.length) { + return false + } + let counts = new Array(26).fill(0) + for (let i = 0; i < s.length; ++i) { + counts[s.charCodeAt(i) - 'a'.charCodeAt(0)]++ + counts[t.charCodeAt(i) - 'a'.charCodeAt(0)]-- + } + return counts.every((c) => c === 0) +} + +export { isAnagram } diff --git a/src/main/ts/g0201_0300/s0289_game_of_life/readme.md b/src/main/ts/g0201_0300/s0289_game_of_life/readme.md new file mode 100644 index 0000000..1f38ba1 --- /dev/null +++ b/src/main/ts/g0201_0300/s0289_game_of_life/readme.md @@ -0,0 +1,42 @@ +289\. Game of Life + +Medium + +According to [Wikipedia's article](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life): "The **Game of Life**, also known simply as **Life**, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." + +The board is made up of an `m x n` grid of cells, where each cell has an initial state: **live** (represented by a `1`) or **dead** (represented by a `0`). Each cell interacts with its [eight neighbors](https://en.wikipedia.org/wiki/Moore_neighborhood) (horizontal, vertical, diagonal) using the following four rules (taken from the above Wikipedia article): + +1. Any live cell with fewer than two live neighbors dies as if caused by under-population. +2. Any live cell with two or three live neighbors lives on to the next generation. +3. Any live cell with more than three live neighbors dies, as if by over-population. +4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction. + +The next state is created by applying the above rules simultaneously to every cell in the current state, where births and deaths occur simultaneously. Given the current state of the `m x n` grid `board`, return _the next state_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/12/26/grid1.jpg) + +**Input:** board = [[0,1,0],[0,0,1],[1,1,1],[0,0,0]] + +**Output:** [[0,0,0],[1,0,1],[0,1,1],[0,1,0]] + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2020/12/26/grid2.jpg) + +**Input:** board = [[1,1],[1,0]] + +**Output:** [[1,1],[1,1]] + +**Constraints:** + +* `m == board.length` +* `n == board[i].length` +* `1 <= m, n <= 25` +* `board[i][j]` is `0` or `1`. + +**Follow up:** + +* Could you solve it in-place? Remember that the board needs to be updated simultaneously: You cannot update some cells first and then use their updated values to update other cells. +* In this question, we represent the board using a 2D array. In principle, the board is infinite, which would cause problems when the active area encroaches upon the border of the array (i.e., live cells reach the border). How would you address these problems? diff --git a/src/main/ts/g0201_0300/s0289_game_of_life/solution.ts b/src/main/ts/g0201_0300/s0289_game_of_life/solution.ts new file mode 100644 index 0000000..87a148f --- /dev/null +++ b/src/main/ts/g0201_0300/s0289_game_of_life/solution.ts @@ -0,0 +1,40 @@ +// #Medium #Array #Matrix #Simulation #Top_Interview_150_Matrix +// #2025_04_12_Time_0_ms_(100.00%)_Space_53.84_MB_(79.20%) + +/** + * Do not return anything, modify board in-place instead. + */ +function gameOfLife(board: number[][]): void { + const m = board.length + const n = board[0].length + + for (let i = 0; i < m; i++) { + for (let j = 0; j < n; j++) { + const liveNeighbors = countLives(board, i, j, m, n) + if (board[i][j] === 0 && liveNeighbors === 3) { + board[i][j] = 2 + } else if (board[i][j] === 1 && (liveNeighbors === 2 || liveNeighbors === 3)) { + board[i][j] = 3 + } + } + } + + for (let i = 0; i < m; i++) { + for (let j = 0; j < n; j++) { + board[i][j] >>= 1 + } + } +} + +function countLives(board: number[][], i: number, j: number, m: number, n: number): number { + let lives = 0 + for (let r = Math.max(0, i - 1); r <= Math.min(m - 1, i + 1); r++) { + for (let c = Math.max(0, j - 1); c <= Math.min(n - 1, j + 1); c++) { + lives += board[r][c] & 1 + } + } + lives -= board[i][j] & 1 + return lives +} + +export { gameOfLife } diff --git a/src/main/ts/g0201_0300/s0290_word_pattern/readme.md b/src/main/ts/g0201_0300/s0290_word_pattern/readme.md new file mode 100644 index 0000000..f69f9f9 --- /dev/null +++ b/src/main/ts/g0201_0300/s0290_word_pattern/readme.md @@ -0,0 +1,40 @@ +290\. Word Pattern + +Easy + +Given a `pattern` and a string `s`, find if `s` follows the same pattern. + +Here **follow** means a full match, such that there is a bijection between a letter in `pattern` and a **non-empty** word in `s`. + +**Example 1:** + +**Input:** pattern = "abba", s = "dog cat cat dog" + +**Output:** true + +**Example 2:** + +**Input:** pattern = "abba", s = "dog cat cat fish" + +**Output:** false + +**Example 3:** + +**Input:** pattern = "aaaa", s = "dog cat cat dog" + +**Output:** false + +**Example 4:** + +**Input:** pattern = "abba", s = "dog dog dog dog" + +**Output:** false + +**Constraints:** + +* `1 <= pattern.length <= 300` +* `pattern` contains only lower-case English letters. +* `1 <= s.length <= 3000` +* `s` contains only lower-case English letters and spaces `' '`. +* `s` **does not contain** any leading or trailing spaces. +* All the words in `s` are separated by a **single space**. diff --git a/src/main/ts/g0201_0300/s0290_word_pattern/solution.ts b/src/main/ts/g0201_0300/s0290_word_pattern/solution.ts new file mode 100644 index 0000000..068c6b8 --- /dev/null +++ b/src/main/ts/g0201_0300/s0290_word_pattern/solution.ts @@ -0,0 +1,27 @@ +// #Easy #String #Hash_Table #Data_Structure_II_Day_7_String #Top_Interview_150_Hashmap +// #2025_04_12_Time_0_ms_(100.00%)_Space_55.01_MB_(70.10%) + +function wordPattern(pattern: string, s: string): boolean { + const map = new Map(); + const words = s.split(" "); + if (words.length !== pattern.length) { + return false; + } + for (let i = 0; i < pattern.length; i++) { + const char = pattern[i]; + const word = words[i]; + if (!map.has(char)) { + if ([...map.values()].includes(word)) { + return false; + } + map.set(char, word); + } else { + if (map.get(char) !== word) { + return false; + } + } + } + return true; +} + +export { wordPattern } diff --git a/src/test/ts/g0201_0300/s0224_basic_calculator/solution.test.ts b/src/test/ts/g0201_0300/s0224_basic_calculator/solution.test.ts new file mode 100644 index 0000000..dfab961 --- /dev/null +++ b/src/test/ts/g0201_0300/s0224_basic_calculator/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { calculate } from 'src/main/ts/g0201_0300/s0224_basic_calculator/solution' +import { expect, test } from 'vitest' + +test('calculate', () => { + expect(calculate('1 + 1')).toEqual(2) +}) + +test('calculate2', () => { + expect(calculate(' 2-1 + 2 ')).toEqual(3) +}) + +test('calculate3', () => { + expect(calculate('(1+(4+5+2)-3)+(6+8)')).toEqual(23) +}) diff --git a/src/test/ts/g0201_0300/s0228_summary_ranges/solution.test.ts b/src/test/ts/g0201_0300/s0228_summary_ranges/solution.test.ts new file mode 100644 index 0000000..d70b76e --- /dev/null +++ b/src/test/ts/g0201_0300/s0228_summary_ranges/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { summaryRanges } from 'src/main/ts/g0201_0300/s0228_summary_ranges/solution' +import { expect, test } from 'vitest' + +test('summaryRanges', () => { + expect(summaryRanges([0, 1, 2, 4, 5, 7])).toEqual(['0->2', '4->5', '7']) +}) + +test('summaryRanges2', () => { + expect(summaryRanges([0, 2, 3, 4, 6, 8, 9])).toEqual(['0', '2->4', '6', '8->9']) +}) diff --git a/src/test/ts/g0201_0300/s0242_valid_anagram/solution.test.ts b/src/test/ts/g0201_0300/s0242_valid_anagram/solution.test.ts new file mode 100644 index 0000000..99c010f --- /dev/null +++ b/src/test/ts/g0201_0300/s0242_valid_anagram/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { isAnagram } from 'src/main/ts/g0201_0300/s0242_valid_anagram/solution' +import { expect, test } from 'vitest' + +test('isAnagram', () => { + expect(isAnagram('anagram', 'nagaram')).toEqual(true) +}) + +test('isAnagram2', () => { + expect(isAnagram('rat', 'car')).toEqual(false) +}) diff --git a/src/test/ts/g0201_0300/s0289_game_of_life/solution.test.ts b/src/test/ts/g0201_0300/s0289_game_of_life/solution.test.ts new file mode 100644 index 0000000..03f4c33 --- /dev/null +++ b/src/test/ts/g0201_0300/s0289_game_of_life/solution.test.ts @@ -0,0 +1,31 @@ +// tslint:disable:no-magic-numbers +import { gameOfLife } from 'src/main/ts/g0201_0300/s0289_game_of_life/solution' +import { expect, test } from 'vitest' + +test('gameOfLife', () => { + const board = [ + [0, 1, 0], + [0, 0, 1], + [1, 1, 1], + [0, 0, 0], + ] + gameOfLife(board) + expect(board).toEqual([ + [0, 0, 0], + [1, 0, 1], + [0, 1, 1], + [0, 1, 0], + ]) +}) + +test('gameOfLife2', () => { + const board = [ + [1, 1], + [1, 0], + ] + gameOfLife(board) + expect(board).toEqual([ + [1, 1], + [1, 1], + ]) +}) diff --git a/src/test/ts/g0201_0300/s0290_word_pattern/solution.test.ts b/src/test/ts/g0201_0300/s0290_word_pattern/solution.test.ts new file mode 100644 index 0000000..2f1d6f2 --- /dev/null +++ b/src/test/ts/g0201_0300/s0290_word_pattern/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { wordPattern } from 'src/main/ts/g0201_0300/s0290_word_pattern/solution' +import { expect, test } from 'vitest' + +test('wordPattern', () => { + expect(wordPattern('abba', 'dog cat cat dog')).toEqual(true) +}) + +test('wordPattern2', () => { + expect(wordPattern('abba', 'dog cat cat fish')).toEqual(false) +}) + +test('wordPattern3', () => { + expect(wordPattern('aaaa', 'dog cat cat dog')).toEqual(false) +}) From a1ea4d7dc919bcb4b974b78d73b7ef7aede18e14 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sun, 13 Apr 2025 06:13:15 +0300 Subject: [PATCH 41/49] Improved task 290 --- .../g0201_0300/s0290_word_pattern/solution.ts | 18 +++++++++--------- .../s0290_word_pattern/solution.test.ts | 12 ++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main/ts/g0201_0300/s0290_word_pattern/solution.ts b/src/main/ts/g0201_0300/s0290_word_pattern/solution.ts index 068c6b8..4bc7476 100644 --- a/src/main/ts/g0201_0300/s0290_word_pattern/solution.ts +++ b/src/main/ts/g0201_0300/s0290_word_pattern/solution.ts @@ -2,26 +2,26 @@ // #2025_04_12_Time_0_ms_(100.00%)_Space_55.01_MB_(70.10%) function wordPattern(pattern: string, s: string): boolean { - const map = new Map(); - const words = s.split(" "); + const map = new Map() + const words = s.split(' ') if (words.length !== pattern.length) { - return false; + return false } for (let i = 0; i < pattern.length; i++) { - const char = pattern[i]; - const word = words[i]; + const char = pattern[i] + const word = words[i] if (!map.has(char)) { if ([...map.values()].includes(word)) { - return false; + return false } - map.set(char, word); + map.set(char, word) } else { if (map.get(char) !== word) { - return false; + return false } } } - return true; + return true } export { wordPattern } diff --git a/src/test/ts/g0201_0300/s0290_word_pattern/solution.test.ts b/src/test/ts/g0201_0300/s0290_word_pattern/solution.test.ts index 2f1d6f2..5a45dda 100644 --- a/src/test/ts/g0201_0300/s0290_word_pattern/solution.test.ts +++ b/src/test/ts/g0201_0300/s0290_word_pattern/solution.test.ts @@ -13,3 +13,15 @@ test('wordPattern2', () => { test('wordPattern3', () => { expect(wordPattern('aaaa', 'dog cat cat dog')).toEqual(false) }) + +test('wordPattern4', () => { + expect(wordPattern('a', 'dog cat')).toEqual(false) +}) + +test('wordPattern5', () => { + expect(wordPattern('a', 'dog')).toEqual(true) +}) + +test('wordPattern6', () => { + expect(wordPattern('ab', 'dog dog')).toEqual(false) +}) From 9a21aa25f8eb74c4c72b96f0178c848e761daa01 Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Mon, 14 Apr 2025 23:33:20 +0700 Subject: [PATCH 42/49] Added tasks 373-433 --- README.md | 15 +++ .../readme.md | 40 ++++++++ .../solution.ts | 86 +++++++++++++++++ .../ts/g0301_0400/s0383_ransom_note/readme.md | 30 ++++++ .../g0301_0400/s0383_ransom_note/solution.ts | 20 ++++ .../g0301_0400/s0392_is_subsequence/readme.md | 27 ++++++ .../s0392_is_subsequence/solution.ts | 25 +++++ .../s0427_construct_quad_tree/readme.md | 78 ++++++++++++++++ .../s0427_construct_quad_tree/solution.ts | 92 +++++++++++++++++++ .../s0433_minimum_genetic_mutation/readme.md | 41 +++++++++ .../solution.ts | 41 +++++++++ .../solution.test.ts | 18 ++++ .../s0383_ransom_note/solution.test.ts | 15 +++ .../s0392_is_subsequence/solution.test.ts | 11 +++ .../solution.test.ts | 27 ++++++ .../solution.test.ts | 11 +++ 16 files changed, 577 insertions(+) create mode 100644 src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/readme.md create mode 100644 src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts create mode 100644 src/main/ts/g0301_0400/s0383_ransom_note/readme.md create mode 100644 src/main/ts/g0301_0400/s0383_ransom_note/solution.ts create mode 100644 src/main/ts/g0301_0400/s0392_is_subsequence/readme.md create mode 100644 src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts create mode 100644 src/main/ts/g0401_0500/s0427_construct_quad_tree/readme.md create mode 100644 src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts create mode 100644 src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/readme.md create mode 100644 src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts create mode 100644 src/test/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.test.ts create mode 100644 src/test/ts/g0301_0400/s0383_ransom_note/solution.test.ts create mode 100644 src/test/ts/g0301_0400/s0392_is_subsequence/solution.test.ts create mode 100644 src/test/ts/g0401_0500/s0427_construct_quad_tree/solution.test.ts create mode 100644 src/test/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.test.ts diff --git a/README.md b/README.md index 7a7fb31..ef5837c 100644 --- a/README.md +++ b/README.md @@ -319,6 +319,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers | 0 | 100.00 | 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 @@ -579,6 +580,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0433 |[Minimum Genetic Mutation](src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts)| Medium | String, Hash_Table, Breadth_First_Search | 0 | 100.00 | 0127 |[Word Ladder](src/main/ts/g0101_0200/s0127_word_ladder/solution.ts)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 41 | 95.63 #### Day 13 Graph Theory @@ -655,6 +657,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0205 |[Isomorphic Strings](src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts)| Easy | String, Hash_Table | 3 | 96.02 +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers | 0 | 100.00 #### Day 3 Linked List @@ -918,6 +921,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers | 0 | 100.00 | 0125 |[Valid Palindrome](src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers | 0 | 100.00 | 0026 |[Remove Duplicates from Sorted Array](src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 @@ -1062,6 +1066,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0125 |[Valid Palindrome](src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers | 0 | 100.00 +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers | 0 | 100.00 | 0167 |[Two Sum II - Input Array Is Sorted](src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts)| Medium | Array, Binary_Search, Two_Pointers | 0 | 100.00 | 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 @@ -1089,6 +1094,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0383 |[Ransom Note](src/main/ts/g0301_0400/s0383_ransom_note/solution.ts)| Easy | String, Hash_Table, Counting | 4 | 97.40 | 0205 |[Isomorphic Strings](src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts)| Easy | String, Hash_Table | 3 | 96.02 | 0290 |[Word Pattern](src/main/ts/g0201_0300/s0290_word_pattern/solution.ts)| Easy | String, Hash_Table | 0 | 100.00 | 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting | 4 | 97.99 @@ -1177,6 +1183,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0433 |[Minimum Genetic Mutation](src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts)| Medium | String, Hash_Table, Breadth_First_Search | 0 | 100.00 | 0127 |[Word Ladder](src/main/ts/g0101_0200/s0127_word_ladder/solution.ts)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 41 | 95.63 #### Top Interview 150 Trie @@ -1205,6 +1212,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 | 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 36 | 44.94 +| 0427 |[Construct Quad Tree](src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts)| Medium | Array, Tree, Matrix, Divide_and_Conquer | ew 150 | ew 150 Divide and Conquer | 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 4 | 97.65 #### Top Interview 150 Kadane's Algorithm @@ -1230,6 +1238,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 +| 0373 |[Find K Pairs with Smallest Sums](src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts)| Medium | Array, Heap_Priority_Queue | 42 | 85.15 | 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 106 | 92.31 #### Top Interview 150 Bit Manipulation @@ -1315,6 +1324,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0383 |[Ransom Note](src/main/ts/g0301_0400/s0383_ransom_note/solution.ts)| Easy | String, Hash_Table, Counting | 4 | 97.40 | 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting | 4 | 97.99 #### Day 7 Linked List @@ -1741,8 +1751,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0494 |[Target Sum](src/main/ts/g0401_0500/s0494_target_sum/solution.ts)| Medium | Array, Dynamic_Programming, Backtracking, Big_O_Time_O(n\*(sum+s))_Space_O(n\*(sum+s)) | 24 | 83.43 | 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Programming_Skills_II_Day_12, Level_1_Day_12_Sliding_Window/Two_Pointer, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 | 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Big_O_Time_O(n)_Space_O(n) | 3 | 86.41 +| 0433 |[Minimum Genetic Mutation](src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts)| Medium | String, Hash_Table, Breadth_First_Search, Graph_Theory_I_Day_12_Breadth_First_Search, Top_Interview_150_Graph_BFS | 0 | 100.00 +| 0427 |[Construct Quad Tree](src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts)| Medium | Array, Tree, Matrix, Divide_and_Conquer | ew 150 | ew 150 Divide and Conquer | 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Level_2_Day_13_Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 33 | 93.24 | 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Level_1_Day_14_Stack, Udemy_Strings, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers, Dynamic_Programming_I_Day_19, Level_1_Day_2_String, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers | 0 | 100.00 +| 0383 |[Ransom Note](src/main/ts/g0301_0400/s0383_ransom_note/solution.ts)| Easy | String, Hash_Table, Counting, Data_Structure_I_Day_6_String, Top_Interview_150_Hashmap | 4 | 97.40 +| 0373 |[Find K Pairs with Smallest Sums](src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts)| Medium | Array, Heap_Priority_Queue, Top_Interview_150_Heap | 42 | 85.15 | 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Data_Structure_II_Day_20_Heap_Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(k) | 7 | 87.13 | 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Udemy_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 1 | 89.22 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_20, Level_2_Day_12_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 diff --git a/src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/readme.md b/src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/readme.md new file mode 100644 index 0000000..71e2c20 --- /dev/null +++ b/src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/readme.md @@ -0,0 +1,40 @@ +373\. Find K Pairs with Smallest Sums + +Medium + +You are given two integer arrays `nums1` and `nums2` sorted in **ascending order** and an integer `k`. + +Define a pair `(u, v)` which consists of one element from the first array and one element from the second array. + +Return _the_ `k` _pairs_ (u1, v1), (u2, v2), ..., (uk, vk) _with the smallest sums_. + +**Example 1:** + +**Input:** nums1 = [1,7,11], nums2 = [2,4,6], k = 3 + +**Output:** [[1,2],[1,4],[1,6]] + +**Explanation:** The first 3 pairs are returned from the sequence: [1,2],[1,4],[1,6],[7,2],[7,4],[11,2],[7,6],[11,4],[11,6] + +**Example 2:** + +**Input:** nums1 = [1,1,2], nums2 = [1,2,3], k = 2 + +**Output:** [[1,1],[1,1]] + +**Explanation:** The first 2 pairs are returned from the sequence: [1,1],[1,1],[1,2],[2,1],[1,2],[2,2],[1,3],[1,3],[2,3] + +**Example 3:** + +**Input:** nums1 = [1,2], nums2 = [3], k = 3 + +**Output:** [[1,3],[2,3]] + +**Explanation:** All possible pairs are returned from the sequence: [1,3],[2,3] + +**Constraints:** + +* 1 <= nums1.length, nums2.length <= 105 +* -109 <= nums1[i], nums2[i] <= 109 +* `nums1` and `nums2` both are sorted in **ascending order**. +* `1 <= k <= 1000` diff --git a/src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts b/src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts new file mode 100644 index 0000000..79b22dc --- /dev/null +++ b/src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts @@ -0,0 +1,86 @@ +// #Medium #Array #Heap_Priority_Queue #Top_Interview_150_Heap +// #2025_04_14_Time_42_ms_(85.15%)_Space_85.10_MB_(76.24%) + +class MinHeap { + private heap: { sum: number; i: number; j: number }[] + + constructor() { + this.heap = [] + } + + push(val: { sum: number; i: number; j: number }) { + this.heap.push(val) + this.bubbleUp() + } + + pop(): { sum: number; i: number; j: number } | undefined { + if (this.heap.length === 0) { + return undefined + } + if (this.heap.length === 1) { + return this.heap.pop() + } + const min = this.heap[0] + this.heap[0] = this.heap.pop()! + this.bubbleDown() + return min + } + + isEmpty(): boolean { + return this.heap.length === 0 + } + + private bubbleUp() { + let index = this.heap.length - 1 + while (index > 0) { + let parentIndex = Math.floor((index - 1) / 2) + if (this.heap[parentIndex].sum <= this.heap[index].sum) { + break + } + ;[this.heap[parentIndex], this.heap[index]] = [this.heap[index], this.heap[parentIndex]] + index = parentIndex + } + } + + private bubbleDown() { + let index = 0 + let length = this.heap.length + while (true) { + let leftChildIndex = 2 * index + 1 + let rightChildIndex = 2 * index + 2 + let smallest = index + if (leftChildIndex < length && this.heap[leftChildIndex].sum < this.heap[smallest].sum) { + smallest = leftChildIndex + } + if (rightChildIndex < length && this.heap[rightChildIndex].sum < this.heap[smallest].sum) { + smallest = rightChildIndex + } + if (smallest === index) { + break + } + ;[this.heap[index], this.heap[smallest]] = [this.heap[smallest], this.heap[index]] + index = smallest + } + } +} + +function kSmallestPairs(nums1: number[], nums2: number[], k: number): number[][] { + let ans: number[][] = [] + if (nums1.length === 0 || nums2.length === 0 || k === 0) { + return ans + } + let minHeap = new MinHeap() + for (let i = 0; i < Math.min(nums1.length, k); i++) { + minHeap.push({ sum: nums1[i] + nums2[0], i, j: 0 }) + } + while (k-- > 0 && !minHeap.isEmpty()) { + let { i, j } = minHeap.pop()! + ans.push([nums1[i], nums2[j]]) + if (j + 1 < nums2.length) { + minHeap.push({ sum: nums1[i] + nums2[j + 1], i, j: j + 1 }) + } + } + return ans +} + +export { kSmallestPairs } diff --git a/src/main/ts/g0301_0400/s0383_ransom_note/readme.md b/src/main/ts/g0301_0400/s0383_ransom_note/readme.md new file mode 100644 index 0000000..6e85a1f --- /dev/null +++ b/src/main/ts/g0301_0400/s0383_ransom_note/readme.md @@ -0,0 +1,30 @@ +383\. Ransom Note + +Easy + +Given two stings `ransomNote` and `magazine`, return `true` if `ransomNote` can be constructed from `magazine` and `false` otherwise. + +Each letter in `magazine` can only be used once in `ransomNote`. + +**Example 1:** + +**Input:** ransomNote = "a", magazine = "b" + +**Output:** false + +**Example 2:** + +**Input:** ransomNote = "aa", magazine = "ab" + +**Output:** false + +**Example 3:** + +**Input:** ransomNote = "aa", magazine = "aab" + +**Output:** true + +**Constraints:** + +* 1 <= ransomNote.length, magazine.length <= 105 +* `ransomNote` and `magazine` consist of lowercase English letters. diff --git a/src/main/ts/g0301_0400/s0383_ransom_note/solution.ts b/src/main/ts/g0301_0400/s0383_ransom_note/solution.ts new file mode 100644 index 0000000..7eb3282 --- /dev/null +++ b/src/main/ts/g0301_0400/s0383_ransom_note/solution.ts @@ -0,0 +1,20 @@ +// #Easy #String #Hash_Table #Counting #Data_Structure_I_Day_6_String #Top_Interview_150_Hashmap +// #2025_04_14_Time_4_ms_(97.40%)_Space_57.51_MB_(84.32%) + +function canConstruct(ransomNote: string, magazine: string): boolean { + const freq: number[] = new Array(26).fill(0) + let remaining = ransomNote.length + for (let i = 0; i < remaining; i++) { + freq[ransomNote.charCodeAt(i) - 97]++ + } + for (let i = 0; i < magazine.length && remaining > 0; i++) { + const index = magazine.charCodeAt(i) - 97 + if (freq[index] > 0) { + freq[index]-- + remaining-- + } + } + return remaining === 0 +} + +export { canConstruct } diff --git a/src/main/ts/g0301_0400/s0392_is_subsequence/readme.md b/src/main/ts/g0301_0400/s0392_is_subsequence/readme.md new file mode 100644 index 0000000..8a6dee7 --- /dev/null +++ b/src/main/ts/g0301_0400/s0392_is_subsequence/readme.md @@ -0,0 +1,27 @@ +392\. Is Subsequence + +Easy + +Given two strings `s` and `t`, return `true` _if_ `s` _is a **subsequence** of_ `t`_, or_ `false` _otherwise_. + +A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., `"ace"` is a subsequence of `"abcde"` while `"aec"` is not). + +**Example 1:** + +**Input:** s = "abc", t = "ahbgdc" + +**Output:** true + +**Example 2:** + +**Input:** s = "axc", t = "ahbgdc" + +**Output:** false + +**Constraints:** + +* `0 <= s.length <= 100` +* 0 <= t.length <= 104 +* `s` and `t` consist only of lowercase English letters. + +**Follow up:** Suppose there are lots of incoming `s`, say s1, s2, ..., sk where k >= 109, and you want to check one by one to see if `t` has its subsequence. In this scenario, how would you change your code? diff --git a/src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts b/src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts new file mode 100644 index 0000000..be39263 --- /dev/null +++ b/src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts @@ -0,0 +1,25 @@ +// #Easy #String #Dynamic_Programming #Two_Pointers #Dynamic_Programming_I_Day_19 +// #Level_1_Day_2_String #Udemy_Two_Pointers #Top_Interview_150_Two_Pointers +// #2025_04_14_Time_0_ms_(100.00%)_Space_56.51_MB_(36.22%) + +function isSubsequence(s: string, t: string): boolean { + let i = 0 + let j = 0 + const m = s.length + const n = t.length + if (m === 0) { + return true + } + while (j < n) { + if (s[i] === t[j]) { + i++ + if (i === m) { + return true + } + } + j++ + } + return false +} + +export { isSubsequence } diff --git a/src/main/ts/g0401_0500/s0427_construct_quad_tree/readme.md b/src/main/ts/g0401_0500/s0427_construct_quad_tree/readme.md new file mode 100644 index 0000000..9e9dd3d --- /dev/null +++ b/src/main/ts/g0401_0500/s0427_construct_quad_tree/readme.md @@ -0,0 +1,78 @@ +427\. Construct Quad Tree + +Medium + +Given a `n * n` matrix `grid` of `0's` and `1's` only. We want to represent the `grid` with a Quad-Tree. + +Return _the root of the Quad-Tree_ representing the `grid`. + +Notice that you can assign the value of a node to **True** or **False** when `isLeaf` is **False**, and both are **accepted** in the answer. + +A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes: + +* `val`: True if the node represents a grid of 1's or False if the node represents a grid of 0's. +* `isLeaf`: True if the node is leaf node on the tree or False if the node has the four children. +``` + class Node { + public boolean val; + public boolean isLeaf; + public Node topLeft; + public Node topRight; + public Node bottomLeft; + public Node bottomRight; + } +``` +We can construct a Quad-Tree from a two-dimensional area using the following steps: + +1. If the current grid has the same value (i.e all `1's` or all `0's`) set `isLeaf` True and set `val` to the value of the grid and set the four children to Null and stop. +2. If the current grid has different values, set `isLeaf` to False and set `val` to any value and divide the current grid into four sub-grids as shown in the photo. +3. Recurse for each of the children with the proper sub-grid. + +![](https://assets.leetcode.com/uploads/2020/02/11/new_top.png) + +If you want to know more about the Quad-Tree, you can refer to the [wiki](https://en.wikipedia.org/wiki/Quadtree). + +**Quad-Tree format:** + +The output represents the serialized format of a Quad-Tree using level order traversal, where `null` signifies a path terminator where no node exists below. + +It is very similar to the serialization of the binary tree. The only difference is that the node is represented as a list `[isLeaf, val]`. + +If the value of `isLeaf` or `val` is True we represent it as **1** in the list `[isLeaf, val]` and if the value of `isLeaf` or `val` is False we represent it as **0**. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/02/11/grid1.png) + +**Input:** grid = [[0,1],[1,0]] + +**Output:** [[0,1],[1,0],[1,1],[1,1],[1,0]] + +**Explanation:** + + The explanation of this example is shown below: + Notice that 0 represnts False and 1 represents True in the photo representing the Quad-Tree. + +![](https://assets.leetcode.com/uploads/2020/02/12/e1tree.png) + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2020/02/12/e2mat.png) + +**Input:** grid = [[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0],[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1],[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0]] + +**Output:** [[0,1],[1,1],[0,1],[1,1],[1,0],null,null,null,null,[1,0],[1,0],[1,1],[1,1]] + +**Explanation:** + + All values in the grid are not the same. We divide the grid into four sub-grids. + The topLeft, bottomLeft and bottomRight each has the same value. + The topRight have different values so we divide it into 4 sub-grids where each has the same value. + Explanation is shown in the photo below: + +![](https://assets.leetcode.com/uploads/2020/02/12/e2tree.png) + +**Constraints:** + +* `n == grid.length == grid[i].length` +* n == 2x where `0 <= x <= 6` diff --git a/src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts b/src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts new file mode 100644 index 0000000..7c91dce --- /dev/null +++ b/src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts @@ -0,0 +1,92 @@ +// #Medium #Array #Tree #Matrix #Divide_and_Conquer #Top_Interview_150_Divide_and_Conquer + +class _Node { + val: boolean + isLeaf: boolean + topLeft: _Node | null + topRight: _Node | null + bottomLeft: _Node | null + bottomRight: _Node | null + + constructor( + val: boolean, + isLeaf: boolean, + topLeft: _Node | null = null, + topRight: _Node | null = null, + bottomLeft: _Node | null = null, + bottomRight: _Node | null = null, + ) { + this.val = val + this.isLeaf = isLeaf + this.topLeft = topLeft + this.topRight = topRight + this.bottomLeft = bottomLeft + this.bottomRight = bottomRight + } + + toString(): string { + return ( + this.getNode(this) + + this.getNode(this.topLeft) + + this.getNode(this.topRight) + + this.getNode(this.bottomLeft) + + this.getNode(this.bottomRight) + ) + } + + private getNode(node: _Node | null): string { + if (node === null) return 'null' + return `[${node.isLeaf ? '1' : '0'},${node.val ? '1' : '0'}]` + } +} + +/** + * Definition for _Node. + * class _Node { + * val: boolean + * isLeaf: boolean + * topLeft: _Node | null + * topRight: _Node | null + * bottomLeft: _Node | null + * bottomRight: _Node | null + * constructor(val?: boolean, isLeaf?: boolean, topLeft?: _Node, topRight?: _Node, bottomLeft?: _Node, bottomRight?: _Node) { + * this.val = (val===undefined ? false : val) + * this.isLeaf = (isLeaf===undefined ? false : isLeaf) + * this.topLeft = (topLeft===undefined ? null : topLeft) + * this.topRight = (topRight===undefined ? null : topRight) + * this.bottomLeft = (bottomLeft===undefined ? null : bottomLeft) + * this.bottomRight = (bottomRight===undefined ? null : bottomRight) + * } + * } + */ +function construct(grid: number[][]): _Node | null { + return build(grid, 0, 0, grid.length) +} + +function build(grid: number[][], row: number, col: number, size: number): _Node { + if (size === 1) { + return new _Node(grid[row][col] === 1, true) + } + let isSame = true + let firstVal = grid[row][col] + for (let i = row; i < row + size; i++) { + for (let j = col; j < col + size; j++) { + if (grid[i][j] !== firstVal) { + isSame = false + break + } + } + if (!isSame) break + } + if (isSame) { + return new _Node(firstVal === 1, true) + } + let newSize = size / 2 + let topLeft = build(grid, row, col, newSize) + let topRight = build(grid, row, col + newSize, newSize) + let bottomLeft = build(grid, row + newSize, col, newSize) + let bottomRight = build(grid, row + newSize, col + newSize, newSize) + return new _Node(true, false, topLeft, topRight, bottomLeft, bottomRight) +} + +export { construct } diff --git a/src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/readme.md b/src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/readme.md new file mode 100644 index 0000000..852b252 --- /dev/null +++ b/src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/readme.md @@ -0,0 +1,41 @@ +433\. Minimum Genetic Mutation + +Medium + +A gene string can be represented by an 8-character long string, with choices from `'A'`, `'C'`, `'G'`, and `'T'`. + +Suppose we need to investigate a mutation from a gene string `start` to a gene string `end` where one mutation is defined as one single character changed in the gene string. + +* For example, `"AACCGGTT" --> "AACCGGTA"` is one mutation. + +There is also a gene bank `bank` that records all the valid gene mutations. A gene must be in `bank` to make it a valid gene string. + +Given the two gene strings `start` and `end` and the gene bank `bank`, return _the minimum number of mutations needed to mutate from_ `start` _to_ `end`. If there is no such a mutation, return `-1`. + +Note that the starting point is assumed to be valid, so it might not be included in the bank. + +**Example 1:** + +**Input:** start = "AACCGGTT", end = "AACCGGTA", bank = ["AACCGGTA"] + +**Output:** 1 + +**Example 2:** + +**Input:** start = "AACCGGTT", end = "AAACGGTA", bank = ["AACCGGTA","AACCGCTA","AAACGGTA"] + +**Output:** 2 + +**Example 3:** + +**Input:** start = "AAAAACCC", end = "AACCCCCC", bank = ["AAAACCCC","AAACCCCC","AACCCCCC"] + +**Output:** 3 + +**Constraints:** + +* `start.length == 8` +* `end.length == 8` +* `0 <= bank.length <= 10` +* `bank[i].length == 8` +* `start`, `end`, and `bank[i]` consist of only the characters `['A', 'C', 'G', 'T']`. diff --git a/src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts b/src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts new file mode 100644 index 0000000..1768f7e --- /dev/null +++ b/src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts @@ -0,0 +1,41 @@ +// #Medium #String #Hash_Table #Breadth_First_Search #Graph_Theory_I_Day_12_Breadth_First_Search +// #Top_Interview_150_Graph_BFS #2025_04_14_Time_0_ms_(100.00%)_Space_55.27_MB_(71.43%) + +function minMutation(startGene: string, endGene: string, bank: string[]): number { + const isInBank = (set: Set, cur: string): string[] => { + const res: string[] = [] + for (const each of set) { + let diff = 0 + for (let i = 0; i < each.length; i++) { + if (each[i] !== cur[i]) { + diff++ + if (diff > 1) break + } + } + if (diff === 1) { + res.push(each) + } + } + return res + } + const set = new Set(bank) + const queue: string[] = [startGene] + let step = 0 + while (queue.length > 0) { + const curSize = queue.length + for (let i = 0; i < curSize; i++) { + const cur = queue.shift()! + if (cur === endGene) { + return step + } + for (const next of isInBank(set, cur)) { + queue.push(next) + set.delete(next) + } + } + step++ + } + return -1 +} + +export { minMutation } diff --git a/src/test/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.test.ts b/src/test/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.test.ts new file mode 100644 index 0000000..3d634d4 --- /dev/null +++ b/src/test/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.test.ts @@ -0,0 +1,18 @@ +// tslint:disable:no-magic-numbers +import { kSmallestPairs } from 'src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution' +import { expect, test } from 'vitest' + +test('kSmallestPairs', () => { + expect(kSmallestPairs([1, 7, 11], [2, 4, 6], 3)).toEqual([ + [1, 2], + [1, 4], + [1, 6], + ]) +}) + +test('kSmallestPairs2', () => { + expect(kSmallestPairs([1, 1, 2], [1, 2, 3], 2)).toEqual([ + [1, 1], + [1, 1], + ]) +}) diff --git a/src/test/ts/g0301_0400/s0383_ransom_note/solution.test.ts b/src/test/ts/g0301_0400/s0383_ransom_note/solution.test.ts new file mode 100644 index 0000000..809b0bb --- /dev/null +++ b/src/test/ts/g0301_0400/s0383_ransom_note/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { canConstruct } from 'src/main/ts/g0301_0400/s0383_ransom_note/solution' +import { expect, test } from 'vitest' + +test('canConstruct', () => { + expect(canConstruct('a', 'b')).toEqual(false) +}) + +test('canConstruct2', () => { + expect(canConstruct('aa', 'ab')).toEqual(false) +}) + +test('canConstruct3', () => { + expect(canConstruct('aa', 'aab')).toEqual(true) +}) diff --git a/src/test/ts/g0301_0400/s0392_is_subsequence/solution.test.ts b/src/test/ts/g0301_0400/s0392_is_subsequence/solution.test.ts new file mode 100644 index 0000000..8940a9e --- /dev/null +++ b/src/test/ts/g0301_0400/s0392_is_subsequence/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { isSubsequence } from 'src/main/ts/g0301_0400/s0392_is_subsequence/solution' +import { expect, test } from 'vitest' + +test('isSubsequence', () => { + expect(isSubsequence('abc', 'ahbgdc')).toEqual(true) +}) + +test('isSubsequence2', () => { + expect(isSubsequence('axc', 'ahbgdc')).toEqual(false) +}) diff --git a/src/test/ts/g0401_0500/s0427_construct_quad_tree/solution.test.ts b/src/test/ts/g0401_0500/s0427_construct_quad_tree/solution.test.ts new file mode 100644 index 0000000..604cee7 --- /dev/null +++ b/src/test/ts/g0401_0500/s0427_construct_quad_tree/solution.test.ts @@ -0,0 +1,27 @@ +// tslint:disable:no-magic-numbers +import { construct } from 'src/main/ts/g0401_0500/s0427_construct_quad_tree/solution' +import { expect, test } from 'vitest' + +test('construct', () => { + expect( + construct([ + [0, 1], + [1, 0], + ])?.toString(), + ).toEqual('[0,1][1,0][1,1][1,1][1,0]') +}) + +test('construct2', () => { + expect( + construct([ + [1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 0, 0], + ])?.toString(), + ).toEqual('[0,1][1,1][0,1][1,1][1,0]') +}) diff --git a/src/test/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.test.ts b/src/test/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.test.ts new file mode 100644 index 0000000..a4c03da --- /dev/null +++ b/src/test/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { minMutation } from 'src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution' +import { expect, test } from 'vitest' + +test('minMutation', () => { + expect(minMutation('AACCGGTT', 'AACCGGTA', ['AACCGGTA'])).toEqual(1) +}) + +test('minMutation2', () => { + expect(minMutation('AACCGGTT', 'AAACGGTA', ['AACCGGTA', 'AACCGCTA', 'AAACGGTA'])).toEqual(2) +}) From ae738f1763a7494aa6b26f622f17ec9fd995deac Mon Sep 17 00:00:00 2001 From: ThanhNIT <93962044+ThanhNIT@users.noreply.github.com> Date: Tue, 15 Apr 2025 21:17:27 +0700 Subject: [PATCH 43/49] Added tasks 452-918 --- README.md | 13 +++ .../readme.md | 47 ++++++++++ .../solution.ts | 20 +++++ src/main/ts/g0501_0600/s0502_ipo/readme.md | 47 ++++++++++ src/main/ts/g0501_0600/s0502_ipo/solution.ts | 86 +++++++++++++++++++ .../readme.md | 28 ++++++ .../solution.ts | 37 ++++++++ .../readme.md | 26 ++++++ .../solution.ts | 44 ++++++++++ .../s0909_snakes_and_ladders/readme.md | 55 ++++++++++++ .../s0909_snakes_and_ladders/solution.ts | 44 ++++++++++ .../readme.md | 39 +++++++++ .../solution.ts | 25 ++++++ .../solution.test.ts | 36 ++++++++ .../ts/g0501_0600/s0502_ipo/solution.test.ts | 11 +++ .../solution.test.ts | 12 +++ .../solution.test.ts | 12 +++ .../s0909_snakes_and_ladders/solution.test.ts | 25 ++++++ .../solution.test.ts | 15 ++++ 19 files changed, 622 insertions(+) create mode 100644 src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/readme.md create mode 100644 src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts create mode 100644 src/main/ts/g0501_0600/s0502_ipo/readme.md create mode 100644 src/main/ts/g0501_0600/s0502_ipo/solution.ts create mode 100644 src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/readme.md create mode 100644 src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.ts create mode 100644 src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/readme.md create mode 100644 src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts create mode 100644 src/main/ts/g0901_1000/s0909_snakes_and_ladders/readme.md create mode 100644 src/main/ts/g0901_1000/s0909_snakes_and_ladders/solution.ts create mode 100644 src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/readme.md create mode 100644 src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts create mode 100644 src/test/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.test.ts create mode 100644 src/test/ts/g0501_0600/s0502_ipo/solution.test.ts create mode 100644 src/test/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.test.ts create mode 100644 src/test/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.test.ts create mode 100644 src/test/ts/g0901_1000/s0909_snakes_and_ladders/solution.test.ts create mode 100644 src/test/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.test.ts diff --git a/README.md b/README.md index ef5837c..c69e9aa 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0918 |[Maximum Sum Circular Subarray](src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue, Medium, Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 91.04 #### Day 6 @@ -1111,6 +1112,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0228 |[Summary Ranges](src/main/ts/g0201_0300/s0228_summary_ranges/solution.ts)| Easy | Array | 0 | 100.00 | 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 | 0057 |[Insert Interval](src/main/ts/g0001_0100/s0057_insert_interval/solution.ts)| Medium | Array | 0 | 100.00 +| 0452 |[Minimum Number of Arrows to Burst Balloons](src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts)| Medium | Array, Sorting, Greedy | 75 | 98.54 #### Top Interview 150 Stack @@ -1161,6 +1163,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0637 |[Average of Levels in Binary Tree](src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 @@ -1168,6 +1171,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0530 |[Minimum Absolute Difference in BST](src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 0 | 100.00 | 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 @@ -1183,6 +1187,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0909 |[Snakes and Ladders](src/main/ts/g0901_1000/s0909_snakes_and_ladders/solution.ts)| Medium | Array, Breadth_First_Search, Matrix | 5 | 98.27 | 0433 |[Minimum Genetic Mutation](src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts)| Medium | String, Hash_Table, Breadth_First_Search | 0 | 100.00 | 0127 |[Word Ladder](src/main/ts/g0101_0200/s0127_word_ladder/solution.ts)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 41 | 95.63 @@ -1220,6 +1225,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0918 |[Maximum Sum Circular Subarray](src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue, Medium, Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 91.04 #### Top Interview 150 Binary Search @@ -1238,6 +1244,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 +| 0502 |[IPO](src/main/ts/g0501_0600/s0502_ipo/solution.ts)| Hard | Array, Sorting, Greedy, Heap_Priority_Queue | 193 | 89.19 | 0373 |[Find K Pairs with Smallest Sums](src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts)| Medium | Array, Heap_Priority_Queue | 42 | 85.15 | 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 106 | 92.31 @@ -1743,12 +1750,18 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | # | Title | Difficulty | Tag | Time, ms | Time, % |------|----------------|-------------|-------------|----------|--------- | 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_17_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 +| 0918 |[Maximum Sum Circular Subarray](src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue, Medium, Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue, Dynamic_Programming_I_Day_5, Top_Interview_150_Kadane's_Algorithm | 2 | 91.04 +| 0909 |[Snakes and Ladders](src/main/ts/g0901_1000/s0909_snakes_and_ladders/solution.ts)| Medium | Array, Breadth_First_Search, Matrix, Top_Interview_150_Graph_BFS | 5 | 98.27 | 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | String, Hash_Table, Greedy, Two_Pointers, Data_Structure_II_Day_7_String, Big_O_Time_O(n)_Space_O(1) | 4 | 86.89 | 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Programming_Skills_II_Day_6, Big_O_Time_O(n)_Space_O(n) | 18 | 80.57 | 0647 |[Palindromic Substrings](src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts)| Medium | String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n) | 5 | 100.00 +| 0637 |[Average of Levels in Binary Tree](src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Top_Interview_150_Binary_Tree_BFS | 0 | 100.00 | 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Data_Structure_II_Day_5_Array, Big_O_Time_O(n)_Space_O(n) | 14 | 87.34 | 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 1 | 87.16 +| 0530 |[Minimum Absolute Difference in BST](src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Top_Interview_150_Binary_Search_Tree | 0 | 100.00 +| 0502 |[IPO](src/main/ts/g0501_0600/s0502_ipo/solution.ts)| Hard | Array, Sorting, Greedy, Heap_Priority_Queue, Top_Interview_150_Heap | 193 | 89.19 | 0494 |[Target Sum](src/main/ts/g0401_0500/s0494_target_sum/solution.ts)| Medium | Array, Dynamic_Programming, Backtracking, Big_O_Time_O(n\*(sum+s))_Space_O(n\*(sum+s)) | 24 | 83.43 +| 0452 |[Minimum Number of Arrows to Burst Balloons](src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts)| Medium | Array, Sorting, Greedy, Top_Interview_150_Intervals | 75 | 98.54 | 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Programming_Skills_II_Day_12, Level_1_Day_12_Sliding_Window/Two_Pointer, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 | 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Big_O_Time_O(n)_Space_O(n) | 3 | 86.41 | 0433 |[Minimum Genetic Mutation](src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts)| Medium | String, Hash_Table, Breadth_First_Search, Graph_Theory_I_Day_12_Breadth_First_Search, Top_Interview_150_Graph_BFS | 0 | 100.00 diff --git a/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/readme.md b/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/readme.md new file mode 100644 index 0000000..acd3967 --- /dev/null +++ b/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/readme.md @@ -0,0 +1,47 @@ +452\. Minimum Number of Arrows to Burst Balloons + +Medium + +There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array `points` where points[i] = [xstart, xend] denotes a balloon whose **horizontal diameter** stretches between xstart and xend. You do not know the exact y-coordinates of the balloons. + +Arrows can be shot up **directly vertically** (in the positive y-direction) from different points along the x-axis. A balloon with xstart and xend is **burst** by an arrow shot at `x` if xstart <= x <= xend. There is **no limit** to the number of arrows that can be shot. A shot arrow keeps traveling up infinitely, bursting any balloons in its path. + +Given the array `points`, return _the **minimum** number of arrows that must be shot to burst all balloons_. + +**Example 1:** + +**Input:** points = [[10,16],[2,8],[1,6],[7,12]] + +**Output:** 2 + +**Explanation:** The balloons can be burst by 2 arrows: + +- Shoot an arrow at x = 6, bursting the balloons [2,8] and [1,6]. + +- Shoot an arrow at x = 11, bursting the balloons [10,16] and [7,12]. + +**Example 2:** + +**Input:** points = [[1,2],[3,4],[5,6],[7,8]] + +**Output:** 4 + +**Explanation:** One arrow needs to be shot for each balloon for a total of 4 arrows. + +**Example 3:** + +**Input:** points = [[1,2],[2,3],[3,4],[4,5]] + +**Output:** 2 + +**Explanation:** The balloons can be burst by 2 arrows: + +- Shoot an arrow at x = 2, bursting the balloons [1,2] and [2,3]. + +- Shoot an arrow at x = 4, bursting the balloons [3,4] and [4,5]. + +**Constraints:** + +* 1 <= points.length <= 105 +* `points[i].length == 2` +* -231 <= xstart < xend <= 231 - 1 diff --git a/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts b/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts new file mode 100644 index 0000000..208ddb1 --- /dev/null +++ b/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts @@ -0,0 +1,20 @@ +// #Medium #Array #Sorting #Greedy #Top_Interview_150_Intervals +// #2025_04_15_Time_75_ms_(98.54%)_Space_79.44_MB_(62.20%) + +function findMinArrowShots(points: number[][]): number { + if (points.length === 0) { + return 0 + } + points.sort((a, b) => a[1] - b[1]) + let minArrows = 1 + let end = points[0][1] + for (let i = 1; i < points.length; i++) { + if (points[i][0] > end) { + minArrows++ + end = points[i][1] + } + } + return minArrows +} + +export { findMinArrowShots } diff --git a/src/main/ts/g0501_0600/s0502_ipo/readme.md b/src/main/ts/g0501_0600/s0502_ipo/readme.md new file mode 100644 index 0000000..8e36db7 --- /dev/null +++ b/src/main/ts/g0501_0600/s0502_ipo/readme.md @@ -0,0 +1,47 @@ +502\. IPO + +Hard + +Suppose LeetCode will start its **IPO** soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the **IPO**. Since it has limited resources, it can only finish at most `k` distinct projects before the **IPO**. Help LeetCode design the best way to maximize its total capital after finishing at most `k` distinct projects. + +You are given `n` projects where the ith project has a pure profit `profits[i]` and a minimum capital of `capital[i]` is needed to start it. + +Initially, you have `w` capital. When you finish a project, you will obtain its pure profit and the profit will be added to your total capital. + +Pick a list of **at most** `k` distinct projects from given projects to **maximize your final capital**, and return _the final maximized capital_. + +The answer is guaranteed to fit in a 32-bit signed integer. + +**Example 1:** + +**Input:** k = 2, w = 0, profits = [1,2,3], capital = [0,1,1] + +**Output:** 4 + +**Explanation:** + +Since your initial capital is 0, you can only start the project indexed 0. + +After finishing it you will obtain profit 1 and your capital becomes 1. + +With capital 1, you can either start the project indexed 1 or the project indexed 2. + +Since you can choose at most 2 projects, you need to finish the project indexed 2 to get the maximum capital. + +Therefore, output the final maximized capital, which is 0 + 1 + 3 = 4. + +**Example 2:** + +**Input:** k = 3, w = 0, profits = [1,2,3], capital = [0,1,2] + +**Output:** 6 + +**Constraints:** + +* 1 <= k <= 105 +* 0 <= w <= 109 +* `n == profits.length` +* `n == capital.length` +* 1 <= n <= 105 +* 0 <= profits[i] <= 104 +* 0 <= capital[i] <= 109 diff --git a/src/main/ts/g0501_0600/s0502_ipo/solution.ts b/src/main/ts/g0501_0600/s0502_ipo/solution.ts new file mode 100644 index 0000000..72cb0af --- /dev/null +++ b/src/main/ts/g0501_0600/s0502_ipo/solution.ts @@ -0,0 +1,86 @@ +// #Hard #Array #Sorting #Greedy #Heap_Priority_Queue #Top_Interview_150_Heap +// #2025_04_15_Time_193_ms_(89.19%)_Space_102.47_MB_(8.11%) + +class MaxHeap { + private heap: number[]; + + constructor() { + this.heap = []; + } + + push(value: number) { + this.heap.push(value); + this.heapifyUp(); + } + + pop(): number | undefined { + if (this.heap.length === 0) { + return undefined; + } + if (this.heap.length === 1) { + return this.heap.pop(); + } + const max = this.heap[0]; + this.heap[0] = this.heap.pop()!; + this.heapifyDown(); + return max; + } + + isEmpty(): boolean { + return this.heap.length === 0; + } + + private heapifyUp() { + let index = this.heap.length - 1; + while (index > 0) { + let parentIndex = Math.floor((index - 1) / 2); + if (this.heap[parentIndex] >= this.heap[index]) { + break; + } + [this.heap[parentIndex], this.heap[index]] = [this.heap[index], this.heap[parentIndex]]; + index = parentIndex; + } + } + + private heapifyDown() { + let index = 0; + while (true) { + let left = 2 * index + 1; + let right = 2 * index + 2; + let largest = index; + if (left < this.heap.length && this.heap[left] > this.heap[largest]) { + largest = left; + } + if (right < this.heap.length && this.heap[right] > this.heap[largest]) { + largest = right; + } + if (largest === index) break; + [this.heap[index], this.heap[largest]] = [this.heap[largest], this.heap[index]]; + index = largest; + } + } +} + +function findMaximizedCapital(k: number, w: number, profits: number[], capital: number[]): number { + let projects: [number, number][] = []; + const n = profits.length; + for (let i = 0; i < n; i++) { + projects.push([capital[i], profits[i]]); + } + projects.sort((a, b) => a[0] - b[0]); + const maxHeap = new MaxHeap(); + let i = 0; + while (k--) { + while (i < n && projects[i][0] <= w) { + maxHeap.push(projects[i][1]); + i++; + } + if (maxHeap.isEmpty()) { + break; + } + w += maxHeap.pop()!; + } + return w; +} + +export { findMaximizedCapital } diff --git a/src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/readme.md b/src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/readme.md new file mode 100644 index 0000000..64fdaa4 --- /dev/null +++ b/src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/readme.md @@ -0,0 +1,28 @@ +530\. Minimum Absolute Difference in BST + +Easy + +Given the `root` of a Binary Search Tree (BST), return _the minimum absolute difference between the values of any two different nodes in the tree_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/02/05/bst1.jpg) + +**Input:** root = [4,2,6,1,3] + +**Output:** 1 + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2021/02/05/bst2.jpg) + +**Input:** root = [1,0,48,null,null,12,49] + +**Output:** 1 + +**Constraints:** + +* The number of nodes in the tree is in the range [2, 104]. +* 0 <= Node.val <= 105 + +**Note:** This question is the same as 783: [https://leetcode.com/problems/minimum-distance-between-bst-nodes/](https://leetcode.com/problems/minimum-distance-between-bst-nodes/) diff --git a/src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.ts b/src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.ts new file mode 100644 index 0000000..e833b6d --- /dev/null +++ b/src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.ts @@ -0,0 +1,37 @@ +// #Easy #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree #Binary_Search_Tree +// #Top_Interview_150_Binary_Search_Tree #2025_04_15_Time_0_ms_(100.00%)_Space_61.15_MB_(83.13%) + +import { TreeNode } from '../../com_github_leetcode/treenode' + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +function getMinimumDifference(root: TreeNode | null): number { + let ans = Number.MAX_SAFE_INTEGER + let prev: number | null = null + function dfs(node: TreeNode | null) { + if (!node) { + return + } + dfs(node.left) + if (prev !== null) { + ans = Math.min(ans, Math.abs(node.val - prev)) + } + prev = node.val + dfs(node.right) + } + dfs(root) + return ans +} + +export { getMinimumDifference } diff --git a/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/readme.md b/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/readme.md new file mode 100644 index 0000000..5dac74e --- /dev/null +++ b/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/readme.md @@ -0,0 +1,26 @@ +637\. Average of Levels in Binary Tree + +Easy + +Given the `root` of a binary tree, return _the average value of the nodes on each level in the form of an array_. Answers within 10-5 of the actual answer will be accepted. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/03/09/avg1-tree.jpg) + +**Input:** root = [3,9,20,null,null,15,7] + +**Output:** [3.00000,14.50000,11.00000] Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11. Hence return [3, 14.5, 11]. + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2021/03/09/avg2-tree.jpg) + +**Input:** root = [3,9,20,15,7] + +**Output:** [3.00000,14.50000,11.00000] + +**Constraints:** + +* The number of nodes in the tree is in the range [1, 104]. +* -231 <= Node.val <= 231 - 1 diff --git a/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts b/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts new file mode 100644 index 0000000..3bcaa8e --- /dev/null +++ b/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts @@ -0,0 +1,44 @@ +// #Easy #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree +// #Top_Interview_150_Binary_Tree_BFS #2025_04_15_Time_0_ms_(100.00%)_Space_61.24_MB_(69.52%) + +import { TreeNode } from '../../com_github_leetcode/treenode' + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function averageOfLevels(root: TreeNode | null): number[] { + if (!root) { + return [] + } + let res = [] + let queue = [root] + while (queue.length) { + let len = queue.length + let sum = 0 + for (let i = 0; i < len; i++) { + let node = queue.shift() + sum += node.val + if (node.left) { + queue.push(node.left) + } + if (node.right) { + queue.push(node.right) + } + } + res.push(sum / len) + } + return res +} + +export { averageOfLevels } diff --git a/src/main/ts/g0901_1000/s0909_snakes_and_ladders/readme.md b/src/main/ts/g0901_1000/s0909_snakes_and_ladders/readme.md new file mode 100644 index 0000000..50734a0 --- /dev/null +++ b/src/main/ts/g0901_1000/s0909_snakes_and_ladders/readme.md @@ -0,0 +1,55 @@ +909\. Snakes and Ladders + +Medium + +You are given an `n x n` integer matrix `board` where the cells are labeled from `1` to n2 in a [**Boustrophedon style**](https://en.wikipedia.org/wiki/Boustrophedon) starting from the bottom left of the board (i.e. `board[n - 1][0]`) and alternating direction each row. + +You start on square `1` of the board. In each move, starting from square `curr`, do the following: + +* Choose a destination square `next` with a label in the range [curr + 1, min(curr + 6, n2)]. + * This choice simulates the result of a standard **6-sided die roll**: i.e., there are always at most 6 destinations, regardless of the size of the board. +* If `next` has a snake or ladder, you **must** move to the destination of that snake or ladder. Otherwise, you move to `next`. +* The game ends when you reach the square n2. + +A board square on row `r` and column `c` has a snake or ladder if `board[r][c] != -1`. The destination of that snake or ladder is `board[r][c]`. Squares `1` and n2 do not have a snake or ladder. + +Note that you only take a snake or ladder at most once per move. If the destination to a snake or ladder is the start of another snake or ladder, you do **not** follow the subsequent snake or ladder. + +* For example, suppose the board is `[[-1,4],[-1,3]]`, and on the first move, your destination square is `2`. You follow the ladder to square `3`, but do **not** follow the subsequent ladder to `4`. + +Return _the least number of moves required to reach the square_ n2_. If it is not possible to reach the square, return_ `-1`. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2018/09/23/snakes.png) + +**Input:** board = [[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,35,-1,-1,13,-1],[-1,-1,-1,-1,-1,-1],[-1,15,-1,-1,-1,-1]] + +**Output:** 4 + +**Explanation:** + +In the beginning, you start at square 1 (at row 5, column 0). + +You decide to move to square 2 and must take the ladder to square 15. + +You then decide to move to square 17 and must take the snake to square 13. + +You then decide to move to square 14 and must take the ladder to square 35. + +You then decide to move to square 36, ending the game. + +This is the lowest possible number of moves to reach the last square, so return 4. + +**Example 2:** + +**Input:** board = [[-1,-1],[-1,3]] + +**Output:** 1 + +**Constraints:** + +* `n == board.length == board[i].length` +* `2 <= n <= 20` +* `grid[i][j]` is either `-1` or in the range [1, n2]. +* The squares labeled `1` and n2 do not have any ladders or snakes. diff --git a/src/main/ts/g0901_1000/s0909_snakes_and_ladders/solution.ts b/src/main/ts/g0901_1000/s0909_snakes_and_ladders/solution.ts new file mode 100644 index 0000000..c711d28 --- /dev/null +++ b/src/main/ts/g0901_1000/s0909_snakes_and_ladders/solution.ts @@ -0,0 +1,44 @@ +// #Medium #Array #Breadth_First_Search #Matrix #Top_Interview_150_Graph_BFS +// #2025_04_15_Time_5_ms_(98.27%)_Space_59.74_MB_(65.90%) + +function snakesAndLadders(board: number[][]): number { + const size = board.length + const target = size * size + const visited: boolean[] = new Array(target).fill(false) + const queue: number[] = [] + queue.push(1) + visited[0] = true + let steps = 0 + while (queue.length > 0) { + const levelSize = queue.length + for (let i = 0; i < levelSize; i++) { + const current = queue.shift()! + if (current === target) { + return steps + } + for (let next = current + 1; next <= Math.min(current + 6, target); next++) { + if (visited[next - 1]) continue + visited[next - 1] = true + const [row, col] = indexToPosition(next, size) + const destination = board[row][col] === -1 ? next : board[row][col] + queue.push(destination) + } + } + steps++ + } + + return -1 +} + +function indexToPosition(index: number, size: number): [number, number] { + const row = size - 1 - Math.floor((index - 1) / size) + let col: number + if ((size - row) % 2 === 1) { + col = (index - 1) % size + } else { + col = size - 1 - ((index - 1) % size) + } + return [row, col] +} + +export { snakesAndLadders } diff --git a/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/readme.md b/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/readme.md new file mode 100644 index 0000000..60c43ad --- /dev/null +++ b/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/readme.md @@ -0,0 +1,39 @@ +918\. Maximum Sum Circular Subarray + +Medium + +Given a **circular integer array** `nums` of length `n`, return _the maximum possible sum of a non-empty **subarray** of_ `nums`. + +A **circular array** means the end of the array connects to the beginning of the array. Formally, the next element of `nums[i]` is `nums[(i + 1) % n]` and the previous element of `nums[i]` is `nums[(i - 1 + n) % n]`. + +A **subarray** may only include each element of the fixed buffer `nums` at most once. Formally, for a subarray `nums[i], nums[i + 1], ..., nums[j]`, there does not exist `i <= k1`, `k2 <= j` with `k1 % n == k2 % n`. + +**Example 1:** + +**Input:** nums = [1,-2,3,-2] + +**Output:** 3 + +**Explanation:** Subarray [3] has maximum sum 3. + +**Example 2:** + +**Input:** nums = [5,-3,5] + +**Output:** 10 + +**Explanation:** Subarray [5,5] has maximum sum 5 + 5 = 10. + +**Example 3:** + +**Input:** nums = [-3,-2,-3] + +**Output:** -2 + +**Explanation:** Subarray [-2] has maximum sum -2. + +**Constraints:** + +* `n == nums.length` +* 1 <= n <= 3 * 104 +* -3 * 104 <= nums[i] <= 3 * 104 diff --git a/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts b/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts new file mode 100644 index 0000000..8c446f8 --- /dev/null +++ b/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts @@ -0,0 +1,25 @@ +// #Medium #Array #Dynamic_Programming #Divide_and_Conquer #Queue #Monotonic_Queue +// #Medium #Array #Dynamic_Programming #Divide_and_Conquer #Queue #Monotonic_Queue +// #Dynamic_Programming_I_Day_5 #Top_Interview_150_Kadane's_Algorithm +// #2025_04_15_Time_2_ms_(91.04%)_Space_61.54_MB_(85.07%) + +function maxSubarraySumCircular(nums: number[]): number { + let total = 0 + let maxSum = nums[0], + curMax = 0 + let minSum = nums[0], + curMin = 0 + for (let num of nums) { + curMax = Math.max(num, curMax + num) + maxSum = Math.max(maxSum, curMax) + curMin = Math.min(num, curMin + num) + minSum = Math.min(minSum, curMin) + total += num + } + if (maxSum < 0) { + return maxSum + } + return Math.max(maxSum, total - minSum) +} + +export { maxSubarraySumCircular } diff --git a/src/test/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.test.ts b/src/test/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.test.ts new file mode 100644 index 0000000..c9e97e6 --- /dev/null +++ b/src/test/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.test.ts @@ -0,0 +1,36 @@ +// tslint:disable:no-magic-numbers +import { findMinArrowShots } from 'src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution' +import { expect, test } from 'vitest' + +test('findMinArrowShots', () => { + expect( + findMinArrowShots([ + [10, 16], + [2, 8], + [1, 6], + [7, 12], + ]), + ).toEqual(2) +}) + +test('findMinArrowShots2', () => { + expect( + findMinArrowShots([ + [1, 2], + [3, 4], + [5, 6], + [7, 8], + ]), + ).toEqual(4) +}) + +test('findMinArrowShots3', () => { + expect( + findMinArrowShots([ + [1, 2], + [2, 3], + [3, 4], + [4, 5], + ]), + ).toEqual(2) +}) diff --git a/src/test/ts/g0501_0600/s0502_ipo/solution.test.ts b/src/test/ts/g0501_0600/s0502_ipo/solution.test.ts new file mode 100644 index 0000000..6423e12 --- /dev/null +++ b/src/test/ts/g0501_0600/s0502_ipo/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { findMaximizedCapital } from 'src/main/ts/g0501_0600/s0502_ipo/solution' +import { expect, test } from 'vitest' + +test('findMaximizedCapital', () => { + expect(findMaximizedCapital(2, 0, [1, 2, 3], [0, 1, 1])).toEqual(4) +}) + +test('findMaximizedCapital2', () => { + expect(findMaximizedCapital(3, 0, [1, 2, 3], [0, 1, 2])).toEqual(6) +}) diff --git a/src/test/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.test.ts b/src/test/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.test.ts new file mode 100644 index 0000000..04a0a20 --- /dev/null +++ b/src/test/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.test.ts @@ -0,0 +1,12 @@ +// tslint:disable:no-magic-numbers +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' +import { getMinimumDifference } from 'src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution' +import { expect, test } from 'vitest' + +test('getMinimumDifference', () => { + expect(getMinimumDifference(createTreeNode([4, 2, 6, 1, 3]))).toEqual(1) +}) + +test('getMinimumDifference2', () => { + expect(getMinimumDifference(createTreeNode([1, 0, 48, null, null, 12, 49]))).toEqual(1) +}) diff --git a/src/test/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.test.ts b/src/test/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.test.ts new file mode 100644 index 0000000..3babc73 --- /dev/null +++ b/src/test/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.test.ts @@ -0,0 +1,12 @@ +// tslint:disable:no-magic-numbers +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' +import { averageOfLevels } from 'src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution' +import { expect, test } from 'vitest' + +test('averageOfLevels', () => { + expect(averageOfLevels(createTreeNode([3, 9, 20, null, null, 15, 7]))).toEqual([3.0, 14.5, 11.0]) +}) + +test('averageOfLevels2', () => { + expect(averageOfLevels(createTreeNode([3, 9, 20, 15, 7]))).toEqual([3.0, 14.5, 11.0]) +}) diff --git a/src/test/ts/g0901_1000/s0909_snakes_and_ladders/solution.test.ts b/src/test/ts/g0901_1000/s0909_snakes_and_ladders/solution.test.ts new file mode 100644 index 0000000..baf9e6d --- /dev/null +++ b/src/test/ts/g0901_1000/s0909_snakes_and_ladders/solution.test.ts @@ -0,0 +1,25 @@ +// tslint:disable:no-magic-numbers +import { snakesAndLadders } from 'src/main/ts/g0901_1000/s0909_snakes_and_ladders/solution' +import { expect, test } from 'vitest' + +test('snakesAndLadders', () => { + expect( + snakesAndLadders([ + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, 35, -1, -1, 13, -1], + [-1, -1, -1, -1, -1, -1], + [-1, 15, -1, -1, -1, -1], + ]), + ).toEqual(4) +}) + +test('snakesAndLadders2', () => { + expect( + snakesAndLadders([ + [-1, -1], + [-1, 3], + ]), + ).toEqual(1) +}) diff --git a/src/test/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.test.ts b/src/test/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.test.ts new file mode 100644 index 0000000..90b10c6 --- /dev/null +++ b/src/test/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.test.ts @@ -0,0 +1,15 @@ +// tslint:disable:no-magic-numbers +import { maxSubarraySumCircular } from 'src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution' +import { expect, test } from 'vitest' + +test('maxSubarraySumCircular', () => { + expect(maxSubarraySumCircular([1, -2, 3, -2])).toEqual(3) +}) + +test('maxSubarraySumCircular2', () => { + expect(maxSubarraySumCircular([5, -3, 5])).toEqual(10) +}) + +test('maxSubarraySumCircular2', () => { + expect(maxSubarraySumCircular([-3, -2, -3])).toEqual(-2) +}) From fb741da5bbcb1119a05b06351a0fee2321ed5742 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Wed, 16 Apr 2025 06:31:08 +0300 Subject: [PATCH 44/49] Added tasks 100, 274, 380, 399 --- README.md | 15 +++- .../solution.ts | 13 ++++ .../ts/g0001_0100/s0100_same_tree/readme.md | 36 +++++++++ .../ts/g0001_0100/s0100_same_tree/solution.ts | 29 ++++++++ .../ts/g0201_0300/s0274_h_index/readme.md | 32 ++++++++ .../ts/g0201_0300/s0274_h_index/solution.ts | 20 +++++ .../readme.md | 38 ++++++++++ .../solution.ts | 51 +++++++++++++ .../s0399_evaluate_division/readme.md | 49 ++++++++++++ .../s0399_evaluate_division/solution.ts | 62 ++++++++++++++++ .../s0427_construct_quad_tree/solution.ts | 1 + src/main/ts/g0501_0600/s0502_ipo/solution.ts | 74 ++++++++++--------- .../s0100_same_tree/solution.test.ts | 16 ++++ .../g0201_0300/s0274_h_index/solution.test.ts | 11 +++ .../solution.test.ts | 25 +++++++ .../s0399_evaluate_division/solution.test.ts | 50 +++++++++++++ 16 files changed, 484 insertions(+), 38 deletions(-) create mode 100644 src/main/ts/g0001_0100/s0100_same_tree/readme.md create mode 100644 src/main/ts/g0001_0100/s0100_same_tree/solution.ts create mode 100644 src/main/ts/g0201_0300/s0274_h_index/readme.md create mode 100644 src/main/ts/g0201_0300/s0274_h_index/solution.ts create mode 100644 src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/readme.md create mode 100644 src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.ts create mode 100644 src/main/ts/g0301_0400/s0399_evaluate_division/readme.md create mode 100644 src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts create mode 100644 src/test/ts/g0001_0100/s0100_same_tree/solution.test.ts create mode 100644 src/test/ts/g0201_0300/s0274_h_index/solution.test.ts create mode 100644 src/test/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.test.ts create mode 100644 src/test/ts/g0301_0400/s0399_evaluate_division/solution.test.ts diff --git a/README.md b/README.md index c69e9aa..2c6669c 100644 --- a/README.md +++ b/README.md @@ -518,6 +518,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0380 |[Insert Delete GetRandom O(1)](src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.ts)| Medium | Array, Hash_Table, Math, Design, Randomized | 73 | 82.52 ### Graph Theory I @@ -834,6 +835,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0100 |[Same Tree](src/main/ts/g0001_0100/s0100_same_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 @@ -976,6 +978,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 | 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 1 | 87.16 +| 0100 |[Same Tree](src/main/ts/g0001_0100/s0100_same_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 @@ -1049,6 +1052,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0122 |[Best Time to Buy and Sell Stock II](src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 0 | 100.00 | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 +| 0274 |[H-Index](src/main/ts/g0201_0300/s0274_h_index/solution.ts)| Medium | Array, Sorting, Counting_Sort | 0 | 100.00 +| 0380 |[Insert Delete GetRandom O(1)](src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.ts)| Medium | Array, Hash_Table, Math, Design, Randomized | 73 | 82.52 | 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 | 0134 |[Gas Station](src/main/ts/g0101_0200/s0134_gas_station/solution.ts)| Medium | Top_Interview_Questions, Array, Greedy | 0 | 100.00 | 0135 |[Candy](src/main/ts/g0101_0200/s0135_candy/solution.ts)| Hard | Array, Greedy | 2 | 96.15 @@ -1145,6 +1150,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0100 |[Same Tree](src/main/ts/g0001_0100/s0100_same_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 @@ -1180,6 +1186,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 +| 0399 |[Evaluate Division](src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts)| Medium | Array, Depth_First_Search, Breadth_First_Search, Graph, Union_Find, Shortest_Path | 0 | 100.00 | 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 | 0210 |[Course Schedule II](src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 2 | 99.76 @@ -1217,7 +1224,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 | 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 36 | 44.94 -| 0427 |[Construct Quad Tree](src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts)| Medium | Array, Tree, Matrix, Divide_and_Conquer | ew 150 | ew 150 Divide and Conquer +| 0427 |[Construct Quad Tree](src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts)| Medium | Array, Tree, Matrix, Divide_and_Conquer | 51 | 96.23 | 0023 |[Merge k Sorted Lists](src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 4 | 97.65 #### Top Interview 150 Kadane's Algorithm @@ -1765,11 +1772,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Programming_Skills_II_Day_12, Level_1_Day_12_Sliding_Window/Two_Pointer, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 | 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Big_O_Time_O(n)_Space_O(n) | 3 | 86.41 | 0433 |[Minimum Genetic Mutation](src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts)| Medium | String, Hash_Table, Breadth_First_Search, Graph_Theory_I_Day_12_Breadth_First_Search, Top_Interview_150_Graph_BFS | 0 | 100.00 -| 0427 |[Construct Quad Tree](src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts)| Medium | Array, Tree, Matrix, Divide_and_Conquer | ew 150 | ew 150 Divide and Conquer +| 0427 |[Construct Quad Tree](src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts)| Medium | Array, Tree, Matrix, Divide_and_Conquer, Top_Interview_150_Divide_and_Conquer | 51 | 96.23 | 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Level_2_Day_13_Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 33 | 93.24 +| 0399 |[Evaluate Division](src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts)| Medium | Array, Depth_First_Search, Breadth_First_Search, Graph, Union_Find, Shortest_Path, Top_Interview_150_Graph_General | 0 | 100.00 | 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Level_1_Day_14_Stack, Udemy_Strings, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers, Dynamic_Programming_I_Day_19, Level_1_Day_2_String, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers | 0 | 100.00 | 0383 |[Ransom Note](src/main/ts/g0301_0400/s0383_ransom_note/solution.ts)| Easy | String, Hash_Table, Counting, Data_Structure_I_Day_6_String, Top_Interview_150_Hashmap | 4 | 97.40 +| 0380 |[Insert Delete GetRandom O(1)](src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.ts)| Medium | Array, Hash_Table, Math, Design, Randomized, Programming_Skills_II_Day_20, Top_Interview_150_Array/String | 73 | 82.52 | 0373 |[Find K Pairs with Smallest Sums](src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts)| Medium | Array, Heap_Priority_Queue, Top_Interview_150_Heap | 42 | 85.15 | 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Data_Structure_II_Day_20_Heap_Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(k) | 7 | 87.13 | 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Udemy_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 1 | 89.22 @@ -1780,6 +1789,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0289 |[Game of Life](src/main/ts/g0201_0300/s0289_game_of_life/solution.ts)| Medium | Array, Matrix, Simulation, Top_Interview_150_Matrix | 0 | 100.00 | 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Binary_Search_II_Day_5, Big_O_Time_O(n)_Space_O(n) | 5 | 88.65 | 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Programming_Skills_I_Day_6_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 +| 0274 |[H-Index](src/main/ts/g0201_0300/s0274_h_index/solution.ts)| Medium | Array, Sorting, Counting_Sort, Top_Interview_150_Array/String | 0 | 100.00 | 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting, Data_Structure_I_Day_6_String, Programming_Skills_I_Day_11_Containers_and_Libraries, Udemy_Strings, Top_Interview_150_Hashmap | 4 | 97.99 | 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Data_Structure_II_Day_4_Array, Binary_Search_II_Day_8, Big_O_Time_O(n+m)_Space_O(1) | 42 | 94.61 | 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Udemy_Arrays, Big_O_Time_O(n\*k)_Space_O(n+k) | 26 | 99.07 @@ -1853,6 +1863,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_15_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS | 0 | 100.00 | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_1_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0100 |[Same Tree](src/main/ts/g0001_0100/s0100_same_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Level_2_Day_15_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General | 0 | 100.00 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_I_Day_14_Tree, Level_1_Day_8_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 | 0097 |[Interleaving String](src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts)| Medium | String, Dynamic_Programming, Top_Interview_150_Multidimensional_DP | 43 | 97.65 | 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Dynamic_Programming_I_Day_11, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 diff --git a/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts b/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts index 13cca78..3405944 100644 --- a/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts +++ b/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts @@ -5,6 +5,19 @@ import { TreeNode } from '../../com_github_leetcode/treenode' +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ function dfs(node: TreeNode | null, lowerBound: number, upperBound: number): boolean { if (!node) return true if (node.val <= lowerBound) return false diff --git a/src/main/ts/g0001_0100/s0100_same_tree/readme.md b/src/main/ts/g0001_0100/s0100_same_tree/readme.md new file mode 100644 index 0000000..0172a56 --- /dev/null +++ b/src/main/ts/g0001_0100/s0100_same_tree/readme.md @@ -0,0 +1,36 @@ +100\. Same Tree + +Easy + +Given the roots of two binary trees `p` and `q`, write a function to check if they are the same or not. + +Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/12/20/ex1.jpg) + +**Input:** p = [1,2,3], q = [1,2,3] + +**Output:** true + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2020/12/20/ex2.jpg) + +**Input:** p = [1,2], q = [1,null,2] + +**Output:** false + +**Example 3:** + +![](https://assets.leetcode.com/uploads/2020/12/20/ex3.jpg) + +**Input:** p = [1,2,1], q = [1,1,2] + +**Output:** false + +**Constraints:** + +* The number of nodes in both trees is in the range `[0, 100]`. +* -104 <= Node.val <= 104 \ No newline at end of file diff --git a/src/main/ts/g0001_0100/s0100_same_tree/solution.ts b/src/main/ts/g0001_0100/s0100_same_tree/solution.ts new file mode 100644 index 0000000..fe8994c --- /dev/null +++ b/src/main/ts/g0001_0100/s0100_same_tree/solution.ts @@ -0,0 +1,29 @@ +// #Easy #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree #Level_2_Day_15_Tree +// #Udemy_Tree_Stack_Queue #Top_Interview_150_Binary_Tree_General +// #2025_04_16_Time_0_ms_(100.00%)_Space_55.66_MB_(67.00%) + +import { TreeNode } from '../../com_github_leetcode/treenode' + +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ +function isSameTree(p: TreeNode | null, q: TreeNode | null): boolean { + if (p === null || q === null) { + return p === null && q === null + } + const b1 = isSameTree(p.left, q.left) + const b2 = isSameTree(p.right, q.right) + return p.val === q.val && b1 && b2 +} + +export { isSameTree } diff --git a/src/main/ts/g0201_0300/s0274_h_index/readme.md b/src/main/ts/g0201_0300/s0274_h_index/readme.md new file mode 100644 index 0000000..73d5909 --- /dev/null +++ b/src/main/ts/g0201_0300/s0274_h_index/readme.md @@ -0,0 +1,32 @@ +274\. H-Index + +Medium + +Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their ith paper, return compute the researcher's `h`**\-index**. + +According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): A scientist has an index `h` if `h` of their `n` papers have at least `h` citations each, and the other `n − h` papers have no more than `h` citations each. + +If there are several possible values for `h`, the maximum one is taken as the `h`**\-index**. + +**Example 1:** + +**Input:** citations = [3,0,6,1,5] + +**Output:** 3 + +**Explanation:** + + [3,0,6,1,5] means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. + Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3. + +**Example 2:** + +**Input:** citations = [1,3,1] + +**Output:** 1 + +**Constraints:** + +* `n == citations.length` +* `1 <= n <= 5000` +* `0 <= citations[i] <= 1000` diff --git a/src/main/ts/g0201_0300/s0274_h_index/solution.ts b/src/main/ts/g0201_0300/s0274_h_index/solution.ts new file mode 100644 index 0000000..d832195 --- /dev/null +++ b/src/main/ts/g0201_0300/s0274_h_index/solution.ts @@ -0,0 +1,20 @@ +// #Medium #Array #Sorting #Counting_Sort #Top_Interview_150_Array/String +// #2025_04_16_Time_0_ms_(100.00%)_Space_54.06_MB_(91.25%) + +function hIndex(citations: number[]): number { + const len = citations.length + const freqArray = new Array(len + 1).fill(0) + for (const citation of citations) { + freqArray[Math.min(citation, len)]++ + } + let totalSoFar = 0 + for (let k = len; k >= 0; k--) { + totalSoFar += freqArray[k] + if (totalSoFar >= k) { + return k + } + } + return -1 +} + +export { hIndex } diff --git a/src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/readme.md b/src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/readme.md new file mode 100644 index 0000000..7e2c591 --- /dev/null +++ b/src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/readme.md @@ -0,0 +1,38 @@ +380\. Insert Delete GetRandom O(1) + +Medium + +Implement the `RandomizedSet` class: + +* `RandomizedSet()` Initializes the `RandomizedSet` object. +* `bool insert(int val)` Inserts an item `val` into the set if not present. Returns `true` if the item was not present, `false` otherwise. +* `bool remove(int val)` Removes an item `val` from the set if present. Returns `true` if the item was present, `false` otherwise. +* `int getRandom()` Returns a random element from the current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the **same probability** of being returned. + +You must implement the functions of the class such that each function works in **average** `O(1)` time complexity. + +**Example 1:** + +**Input** + + ["RandomizedSet", "insert", "remove", "insert", "getRandom", "remove", "insert", "getRandom"] + [[], [1], [2], [2], [], [1], [2], []] + +**Output:** [null, true, false, true, 2, true, false, 2] + +**Explanation:** + + RandomizedSet randomizedSet = new RandomizedSet(); + randomizedSet.insert(1); // Inserts 1 to the set. Returns true as 1 was inserted successfully. + randomizedSet.remove(2); // Returns false as 2 does not exist in the set. + randomizedSet.insert(2); // Inserts 2 to the set, returns true. Set now contains [1,2]. + randomizedSet.getRandom(); // getRandom() should return either 1 or 2 randomly. + randomizedSet.remove(1); // Removes 1 from the set, returns true. Set now contains [2]. + randomizedSet.insert(2); // 2 was already in the set, so return false. + randomizedSet.getRandom(); // Since 2 is the only number in the set, getRandom() will always return 2. + +**Constraints:** + +* -231 <= val <= 231 - 1 +* At most `2 * `105 calls will be made to `insert`, `remove`, and `getRandom`. +* There will be **at least one** element in the data structure when `getRandom` is called. diff --git a/src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.ts b/src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.ts new file mode 100644 index 0000000..6b57db9 --- /dev/null +++ b/src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.ts @@ -0,0 +1,51 @@ +// #Medium #Array #Hash_Table #Math #Design #Randomized #Programming_Skills_II_Day_20 +// #Top_Interview_150_Array/String #2025_04_16_Time_73_ms_(82.52%)_Space_106.13_MB_(72.14%) + +class RandomizedSet { + private rand: () => number + private list: number[] + private map: Map + + constructor() { + this.rand = () => Math.floor(Math.random() * this.list.length) // NOSONAR + this.list = [] + this.map = new Map() + } + + insert(val: number): boolean { + if (this.map.has(val)) { + return false + } + this.map.set(val, this.list.length) + this.list.push(val) + return true + } + + remove(val: number): boolean { + if (!this.map.has(val)) { + return false + } + const swap1 = this.map.get(val)! + const swap2 = this.list.length - 1 + const val2 = this.list[swap2] + this.map.set(val2, swap1) + this.map.delete(val) + this.list[swap1] = val2 + this.list.pop() + return true + } + + getRandom(): number { + return this.list[this.rand()] + } +} + +/** + * Your RandomizedSet object will be instantiated and called as such: + * var obj = new RandomizedSet() + * var param_1 = obj.insert(val) + * var param_2 = obj.remove(val) + * var param_3 = obj.getRandom() + */ + +export { RandomizedSet } diff --git a/src/main/ts/g0301_0400/s0399_evaluate_division/readme.md b/src/main/ts/g0301_0400/s0399_evaluate_division/readme.md new file mode 100644 index 0000000..18a83c5 --- /dev/null +++ b/src/main/ts/g0301_0400/s0399_evaluate_division/readme.md @@ -0,0 +1,49 @@ +399\. Evaluate Division + +Medium + +You are given an array of variable pairs `equations` and an array of real numbers `values`, where equations[i] = [Ai, Bi] and `values[i]` represent the equation Ai / Bi = values[i]. Each Ai or Bi is a string that represents a single variable. + +You are also given some `queries`, where queries[j] = [Cj, Dj] represents the jth query where you must find the answer for Cj / Dj = ?. + +Return _the answers to all queries_. If a single answer cannot be determined, return `-1.0`. + +**Note:** The input is always valid. You may assume that evaluating the queries will not result in division by zero and that there is no contradiction. + +**Example 1:** + +**Input:** equations = [["a","b"],["b","c"]], values = [2.0,3.0], queries = [["a","c"],["b","a"],["a","e"],["a","a"],["x","x"]] + +**Output:** [6.00000,0.50000,-1.00000,1.00000,-1.00000] + +**Explanation:** + +Given: _a / b = 2.0_, _b / c = 3.0_ + +queries are: _a / c = ?_, _b / a = ?_, _a / e = ?_, _a / a = ?_, _x / x = ?_ + +return: [6.0, 0.5, -1.0, 1.0, -1.0 ] + +**Example 2:** + +**Input:** equations = [["a","b"],["b","c"],["bc","cd"]], values = [1.5,2.5,5.0], queries = [["a","c"],["c","b"],["bc","cd"],["cd","bc"]] + +**Output:** [3.75000,0.40000,5.00000,0.20000] + +**Example 3:** + +**Input:** equations = [["a","b"]], values = [0.5], queries = [["a","b"],["b","a"],["a","c"],["x","y"]] + +**Output:** [0.50000,2.00000,-1.00000,-1.00000] + +**Constraints:** + +* `1 <= equations.length <= 20` +* `equations[i].length == 2` +* 1 <= Ai.length, Bi.length <= 5 +* `values.length == equations.length` +* `0.0 < values[i] <= 20.0` +* `1 <= queries.length <= 20` +* `queries[i].length == 2` +* 1 <= Cj.length, Dj.length <= 5 +* Ai, Bi, Cj, Dj consist of lower case English letters and digits. \ No newline at end of file diff --git a/src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts b/src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts new file mode 100644 index 0000000..1c9fa7e --- /dev/null +++ b/src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts @@ -0,0 +1,62 @@ +// #Medium #Array #Depth_First_Search #Breadth_First_Search #Graph #Union_Find #Shortest_Path +// #Top_Interview_150_Graph_General #2025_04_16_Time_0_ms_(100.00%)_Space_54.98_MB_(77.31%) + +type MapType = Map +type RateType = Map + +function calcEquation(equations: [string, string][], values: number[], queries: [string, string][]): number[] { + const root: MapType = new Map() + const rate: RateType = new Map() + for (const [x, y] of equations) { + if (!root.has(x)) { + root.set(x, x) + rate.set(x, 1.0) + } + if (!root.has(y)) { + root.set(y, y) + rate.set(y, 1.0) + } + } + for (let i = 0; i < equations.length; ++i) { + const [x, y] = equations[i] + union(x, y, values[i], root, rate) + } + const result: number[] = [] + for (const [x, y] of queries) { + if (!root.has(x) || !root.has(y)) { + result.push(-1.0) + } else { + const rootX = findRoot(x, x, 1.0, root, rate) + const rootY = findRoot(y, y, 1.0, root, rate) + if (rootX === rootY) { + result.push(rate.get(x)! / rate.get(y)!) + } else { + result.push(-1.0) + } + } + } + return result +} + +function union(x: string, y: string, value: number, root: MapType, rate: RateType): void { + const rootX = findRoot(x, x, 1.0, root, rate) + const rootY = findRoot(y, y, 1.0, root, rate) + + if (rootX !== rootY) { + root.set(rootX, rootY) + const rateX = rate.get(x)! + const rateY = rate.get(y)! + rate.set(rootX, (value * rateY) / rateX) + } +} + +function findRoot(originalX: string, x: string, rateSoFar: number, root: MapType, rate: RateType): string { + if (root.get(x) === x) { + root.set(originalX, x) + rate.set(originalX, rateSoFar * rate.get(x)!) + return x + } + return findRoot(originalX, root.get(x)!, rateSoFar * rate.get(x)!, root, rate) +} + +export { calcEquation } diff --git a/src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts b/src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts index 7c91dce..78a00d8 100644 --- a/src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts +++ b/src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts @@ -1,4 +1,5 @@ // #Medium #Array #Tree #Matrix #Divide_and_Conquer #Top_Interview_150_Divide_and_Conquer +// #2025_04_16_Time_51_ms_(96.23%)_Space_60.83_MB_(77.36%) class _Node { val: boolean diff --git a/src/main/ts/g0501_0600/s0502_ipo/solution.ts b/src/main/ts/g0501_0600/s0502_ipo/solution.ts index 72cb0af..3800003 100644 --- a/src/main/ts/g0501_0600/s0502_ipo/solution.ts +++ b/src/main/ts/g0501_0600/s0502_ipo/solution.ts @@ -2,85 +2,87 @@ // #2025_04_15_Time_193_ms_(89.19%)_Space_102.47_MB_(8.11%) class MaxHeap { - private heap: number[]; + private heap: number[] constructor() { - this.heap = []; + this.heap = [] } push(value: number) { - this.heap.push(value); - this.heapifyUp(); + this.heap.push(value) + this.heapifyUp() } pop(): number | undefined { if (this.heap.length === 0) { - return undefined; + return undefined } if (this.heap.length === 1) { - return this.heap.pop(); + return this.heap.pop() } - const max = this.heap[0]; - this.heap[0] = this.heap.pop()!; - this.heapifyDown(); - return max; + const max = this.heap[0] + this.heap[0] = this.heap.pop()! + this.heapifyDown() + return max } isEmpty(): boolean { - return this.heap.length === 0; + return this.heap.length === 0 } private heapifyUp() { - let index = this.heap.length - 1; + let index = this.heap.length - 1 while (index > 0) { - let parentIndex = Math.floor((index - 1) / 2); + let parentIndex = Math.floor((index - 1) / 2) if (this.heap[parentIndex] >= this.heap[index]) { - break; + break } - [this.heap[parentIndex], this.heap[index]] = [this.heap[index], this.heap[parentIndex]]; - index = parentIndex; + ;[this.heap[parentIndex], this.heap[index]] = [this.heap[index], this.heap[parentIndex]] + index = parentIndex } } private heapifyDown() { - let index = 0; + let index = 0 while (true) { - let left = 2 * index + 1; - let right = 2 * index + 2; - let largest = index; + let left = 2 * index + 1 + let right = 2 * index + 2 + let largest = index if (left < this.heap.length && this.heap[left] > this.heap[largest]) { - largest = left; + largest = left } if (right < this.heap.length && this.heap[right] > this.heap[largest]) { - largest = right; + largest = right } - if (largest === index) break; - [this.heap[index], this.heap[largest]] = [this.heap[largest], this.heap[index]]; - index = largest; + if (largest === index) { + break + } + ;[this.heap[index], this.heap[largest]] = [this.heap[largest], this.heap[index]] + index = largest } } } function findMaximizedCapital(k: number, w: number, profits: number[], capital: number[]): number { - let projects: [number, number][] = []; - const n = profits.length; + let projects: [number, number][] = [] + const n = profits.length for (let i = 0; i < n; i++) { - projects.push([capital[i], profits[i]]); + projects.push([capital[i], profits[i]]) } - projects.sort((a, b) => a[0] - b[0]); - const maxHeap = new MaxHeap(); - let i = 0; + projects.sort((a, b) => a[0] - b[0]) + const maxHeap = new MaxHeap() + let i = 0 while (k--) { while (i < n && projects[i][0] <= w) { - maxHeap.push(projects[i][1]); - i++; + maxHeap.push(projects[i][1]) + i++ } if (maxHeap.isEmpty()) { - break; + break } - w += maxHeap.pop()!; + w += maxHeap.pop()! } - return w; + return w } export { findMaximizedCapital } diff --git a/src/test/ts/g0001_0100/s0100_same_tree/solution.test.ts b/src/test/ts/g0001_0100/s0100_same_tree/solution.test.ts new file mode 100644 index 0000000..6f994a4 --- /dev/null +++ b/src/test/ts/g0001_0100/s0100_same_tree/solution.test.ts @@ -0,0 +1,16 @@ +// tslint:disable:no-magic-numbers +import { createTreeNode } from 'src/main/ts/com_github_leetcode/treenode' +import { isSameTree } from 'src/main/ts/g0001_0100/s0100_same_tree/solution' +import { expect, test } from 'vitest' + +test('isSameTree', () => { + expect(isSameTree(createTreeNode([1, 2, 3]), createTreeNode([1, 2, 3]))).toEqual(true) +}) + +test('isSameTree2', () => { + expect(isSameTree(createTreeNode([1, 2, 3]), createTreeNode([1, null, 2]))).toEqual(false) +}) + +test('isSameTree3', () => { + expect(isSameTree(createTreeNode([1, 2, 1]), createTreeNode([1, 1, 2]))).toEqual(false) +}) diff --git a/src/test/ts/g0201_0300/s0274_h_index/solution.test.ts b/src/test/ts/g0201_0300/s0274_h_index/solution.test.ts new file mode 100644 index 0000000..3e0fb9a --- /dev/null +++ b/src/test/ts/g0201_0300/s0274_h_index/solution.test.ts @@ -0,0 +1,11 @@ +// tslint:disable:no-magic-numbers +import { hIndex } from 'src/main/ts/g0201_0300/s0274_h_index/solution' +import { expect, test } from 'vitest' + +test('hIndex', () => { + expect(hIndex([3, 0, 6, 1, 5])).toEqual(3) +}) + +test('hIndex2', () => { + expect(hIndex([1, 3, 1])).toEqual(1) +}) diff --git a/src/test/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.test.ts b/src/test/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.test.ts new file mode 100644 index 0000000..d025ba4 --- /dev/null +++ b/src/test/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.test.ts @@ -0,0 +1,25 @@ +// tslint:disable:no-magic-numbers +import { RandomizedSet } from 'src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution' +import { expect, test } from 'vitest' + +test('randomizedSet', () => { + const result: string[] = [] + let randomizedSet: RandomizedSet | null = null + result.push(randomizedSet + '') + randomizedSet = new RandomizedSet() + result.push(randomizedSet.insert(1) + '') + result.push(randomizedSet.remove(2) + '') + result.push(randomizedSet.insert(2) + '') + const random = randomizedSet.getRandom() + result.push(random + '') + result.push(randomizedSet.remove(1) + '') + result.push(randomizedSet.insert(2) + '') + result.push(randomizedSet.getRandom() + '') + const expected = ['null', 'true', 'false', 'true', '1', 'true', 'false', '2'] + const expected2 = ['null', 'true', 'false', 'true', '2', 'true', 'false', '2'] + if (random === 1) { + expect(result).toEqual(expected) + } else { + expect(result).toEqual(expected2) + } +}) diff --git a/src/test/ts/g0301_0400/s0399_evaluate_division/solution.test.ts b/src/test/ts/g0301_0400/s0399_evaluate_division/solution.test.ts new file mode 100644 index 0000000..9b22724 --- /dev/null +++ b/src/test/ts/g0301_0400/s0399_evaluate_division/solution.test.ts @@ -0,0 +1,50 @@ +// tslint:disable:no-magic-numbers +import { calcEquation } from 'src/main/ts/g0301_0400/s0399_evaluate_division/solution' +import { expect, test } from 'vitest' + +test('calcEquation', () => { + const equations = [ + ['a', 'b'], + ['b', 'c'], + ] as [string, string][] + const values = [2.0, 3.0] + const queries = [ + ['a', 'c'], + ['b', 'a'], + ['a', 'e'], + ['a', 'a'], + ['x', 'x'], + ] as [string, string][] + const expected = [6.0, 0.5, -1.0, 1.0, -1.0] + expect(calcEquation(equations, values, queries)).toEqual(expected) +}) + +test('calcEquation2', () => { + const equations = [ + ['a', 'b'], + ['b', 'c'], + ['bc', 'cd'], + ] as [string, string][] + const values = [1.5, 2.5, 5.0] + const queries = [ + ['a', 'c'], + ['c', 'b'], + ['bc', 'cd'], + ['cd', 'bc'], + ] as [string, string][] + const expected = [3.75, 0.4, 5.0, 0.2] + expect(calcEquation(equations, values, queries)).toEqual(expected) +}) + +test('calcEquation3', () => { + const equations = [['a', 'b']] as [string, string][] + const values = [0.5] + const queries = [ + ['a', 'b'], + ['b', 'a'], + ['a', 'c'], + ['x', 'y'], + ] as [string, string][] + const expected = [0.5, 2.0, -1.0, -1.0] + expect(calcEquation(equations, values, queries)).toEqual(expected) +}) From 7f37c9e355c7b182aea566283bbcfa73c0ad8ce2 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Wed, 16 Apr 2025 10:25:57 +0300 Subject: [PATCH 45/49] Added tasks 130, 133 --- README.md | 6 ++ .../s0130_surrounded_regions/readme.md | 30 ++++++++ .../s0130_surrounded_regions/solution.ts | 52 ++++++++++++++ .../ts/g0101_0200/s0133_clone_graph/readme.md | 69 +++++++++++++++++++ .../g0101_0200/s0133_clone_graph/solution.ts | 53 ++++++++++++++ .../s0130_surrounded_regions/solution.test.ts | 25 +++++++ .../s0133_clone_graph/solution.test.ts | 22 ++++++ 7 files changed, 257 insertions(+) create mode 100644 src/main/ts/g0101_0200/s0130_surrounded_regions/readme.md create mode 100644 src/main/ts/g0101_0200/s0130_surrounded_regions/solution.ts create mode 100644 src/main/ts/g0101_0200/s0133_clone_graph/readme.md create mode 100644 src/main/ts/g0101_0200/s0133_clone_graph/solution.ts create mode 100644 src/test/ts/g0101_0200/s0130_surrounded_regions/solution.test.ts create mode 100644 src/test/ts/g0101_0200/s0133_clone_graph/solution.test.ts diff --git a/README.md b/README.md index 2c6669c..8445602 100644 --- a/README.md +++ b/README.md @@ -996,6 +996,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 +| 0133 |[Clone Graph](src/main/ts/g0101_0200/s0133_clone_graph/solution.ts)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph | 48 | 82.94 #### Udemy Dynamic Programming @@ -1186,6 +1187,8 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 +| 0130 |[Surrounded Regions](src/main/ts/g0101_0200/s0130_surrounded_regions/solution.ts)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 1 | 99.18 +| 0133 |[Clone Graph](src/main/ts/g0101_0200/s0133_clone_graph/solution.ts)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph | 48 | 82.94 | 0399 |[Evaluate Division](src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts)| Medium | Array, Depth_First_Search, Breadth_First_Search, Graph, Union_Find, Shortest_Path | 0 | 100.00 | 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 | 0210 |[Course Schedule II](src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 2 | 99.76 @@ -1669,6 +1672,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- +| 0130 |[Surrounded Regions](src/main/ts/g0101_0200/s0130_surrounded_regions/solution.ts)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 1 | 99.18 #### Day 9 Recursion Backtracking @@ -1843,7 +1847,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Data_Structure_II_Day_1_Array, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Integers, Top_Interview_150_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0135 |[Candy](src/main/ts/g0101_0200/s0135_candy/solution.ts)| Hard | Array, Greedy, Top_Interview_150_Array/String | 2 | 96.15 | 0134 |[Gas Station](src/main/ts/g0101_0200/s0134_gas_station/solution.ts)| Medium | Top_Interview_Questions, Array, Greedy, Top_Interview_150_Array/String | 0 | 100.00 +| 0133 |[Clone Graph](src/main/ts/g0101_0200/s0133_clone_graph/solution.ts)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph, Udemy_Graph, Top_Interview_150_Graph_General | 48 | 82.94 | 0131 |[Palindrome Partitioning](src/main/ts/g0101_0200/s0131_palindrome_partitioning/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(N\*2^N)_Space_O(2^N\*N) | 13 | 94.96 +| 0130 |[Surrounded Regions](src/main/ts/g0101_0200/s0130_surrounded_regions/solution.ts)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Algorithm_II_Day_8_Breadth_First_Search_Depth_First_Search, Top_Interview_150_Graph_General | 1 | 99.18 | 0129 |[Sum Root to Leaf Numbers](src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Top_Interview_150_Binary_Tree_General | 0 | 100.00 | 0128 |[Longest Consecutive Sequence](src/main/ts/g0101_0200/s0128_longest_consecutive_sequence/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Top_Interview_150_Hashmap, Big_O_Time_O(N_log_N)_Space_O(1) | 34 | 90.07 | 0127 |[Word Ladder](src/main/ts/g0101_0200/s0127_word_ladder/solution.ts)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search, Graph_Theory_I_Day_12_Breadth_First_Search, Top_Interview_150_Graph_BFS | 41 | 95.63 diff --git a/src/main/ts/g0101_0200/s0130_surrounded_regions/readme.md b/src/main/ts/g0101_0200/s0130_surrounded_regions/readme.md new file mode 100644 index 0000000..6b12aaa --- /dev/null +++ b/src/main/ts/g0101_0200/s0130_surrounded_regions/readme.md @@ -0,0 +1,30 @@ +130\. Surrounded Regions + +Medium + +Given an `m x n` matrix `board` containing `'X'` and `'O'`, _capture all regions that are 4-directionally surrounded by_ `'X'`. + +A region is **captured** by flipping all `'O'`s into `'X'`s in that surrounded region. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/02/19/xogrid.jpg) + +**Input:** board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]] + +**Output:** [["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]] + +**Explanation:** Surrounded regions should not be on the border, which means that any 'O' on the border of the board are not flipped to 'X'. Any 'O' that is not on the border and it is not connected to an 'O' on the border will be flipped to 'X'. Two cells are connected if they are adjacent cells connected horizontally or vertically. + +**Example 2:** + +**Input:** board = [["X"]] + +**Output:** [["X"]] + +**Constraints:** + +* `m == board.length` +* `n == board[i].length` +* `1 <= m, n <= 200` +* `board[i][j]` is `'X'` or `'O'`. \ No newline at end of file diff --git a/src/main/ts/g0101_0200/s0130_surrounded_regions/solution.ts b/src/main/ts/g0101_0200/s0130_surrounded_regions/solution.ts new file mode 100644 index 0000000..db3fb81 --- /dev/null +++ b/src/main/ts/g0101_0200/s0130_surrounded_regions/solution.ts @@ -0,0 +1,52 @@ +// #Medium #Top_Interview_Questions #Array #Depth_First_Search #Breadth_First_Search #Matrix +// #Union_Find #Algorithm_II_Day_8_Breadth_First_Search_Depth_First_Search +// #Top_Interview_150_Graph_General #2025_04_16_Time_1_ms_(99.18%)_Space_59.64_MB_(82.97%) + +/** + Do not return anything, modify board in-place instead. + */ +function solve(board: string[][]): void { + if (board.length === 0) { + return + } + const rows = board.length + const cols = board[0].length + const dfs = (board: string[][], row: number, col: number): void => { + if (row < 0 || row >= rows || col < 0 || col >= cols || board[row][col] !== 'O') { + return + } + board[row][col] = '#' + dfs(board, row + 1, col) + dfs(board, row - 1, col) + dfs(board, row, col + 1) + dfs(board, row, col - 1) + } + for (let i = 0; i < cols; i++) { + if (board[0][i] === 'O') { + dfs(board, 0, i) + } + if (board[rows - 1][i] === 'O') { + dfs(board, rows - 1, i) + } + } + for (let i = 0; i < rows; i++) { + if (board[i][0] === 'O') { + dfs(board, i, 0) + } + if (board[i][cols - 1] === 'O') { + dfs(board, i, cols - 1) + } + } + for (let i = 0; i < rows; i++) { + for (let j = 0; j < cols; j++) { + if (board[i][j] === 'O') { + board[i][j] = 'X' + } + if (board[i][j] === '#') { + board[i][j] = 'O' + } + } + } +} + +export { solve } diff --git a/src/main/ts/g0101_0200/s0133_clone_graph/readme.md b/src/main/ts/g0101_0200/s0133_clone_graph/readme.md new file mode 100644 index 0000000..97ec332 --- /dev/null +++ b/src/main/ts/g0101_0200/s0133_clone_graph/readme.md @@ -0,0 +1,69 @@ +133\. Clone Graph + +Medium + +Given a reference of a node in a **[connected](https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph)** undirected graph. + +Return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) (clone) of the graph. + +Each node in the graph contains a value (`int`) and a list (`List[Node]`) of its neighbors. + +class Node { public int val; public List neighbors; } + +**Test case format:** + +For simplicity, each node's value is the same as the node's index (1-indexed). For example, the first node with `val == 1`, the second node with `val == 2`, and so on. The graph is represented in the test case using an adjacency list. + +**An adjacency list** is a collection of unordered **lists** used to represent a finite graph. Each list describes the set of neighbors of a node in the graph. + +The given node will always be the first node with `val = 1`. You must return the **copy of the given node** as a reference to the cloned graph. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2019/11/04/133_clone_graph_question.png) + +**Input:** adjList = [[2,4],[1,3],[2,4],[1,3]] + +**Output:** [[2,4],[1,3],[2,4],[1,3]] + +**Explanation:** + + There are 4 nodes in the graph. + 1st node (val = 1)'s neighbors are 2nd node (val = 2) and 4th node (val = 4). + 2nd node (val = 2)'s neighbors are 1st node (val = 1) and 3rd node (val = 3). + 3rd node (val = 3)'s neighbors are 2nd node (val = 2) and 4th node (val = 4). + 4th node (val = 4)'s neighbors are 1st node (val = 1) and 3rd node (val = 3). + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2020/01/07/graph.png) + +**Input:** adjList = [[]] + +**Output:** [[]] + +**Explanation:** Note that the input contains one empty list. The graph consists of only one node with val = 1 and it does not have any neighbors. + +**Example 3:** + +**Input:** adjList = [] + +**Output:** [] + +**Explanation:** This an empty graph, it does not have any nodes. + +**Example 4:** + +![](https://assets.leetcode.com/uploads/2020/01/07/graph-1.png) + +**Input:** adjList = [[2],[1]] + +**Output:** [[2],[1]] + +**Constraints:** + +* The number of nodes in the graph is in the range `[0, 100]`. +* `1 <= Node.val <= 100` +* `Node.val` is unique for each node. +* There are no repeated edges and no self-loops in the graph. +* The Graph is connected and all nodes can be visited starting from the given node. \ No newline at end of file diff --git a/src/main/ts/g0101_0200/s0133_clone_graph/solution.ts b/src/main/ts/g0101_0200/s0133_clone_graph/solution.ts new file mode 100644 index 0000000..171143e --- /dev/null +++ b/src/main/ts/g0101_0200/s0133_clone_graph/solution.ts @@ -0,0 +1,53 @@ +// #Medium #Hash_Table #Depth_First_Search #Breadth_First_Search #Graph #Udemy_Graph +// #Top_Interview_150_Graph_General #2025_04_16_Time_48_ms_(82.94%)_Space_58.20_MB_(70.18%) + +class Node { + val: number + neighbors: Node[] + + constructor(val: number = 0, neighbors: Node[] = []) { + this.val = val + this.neighbors = neighbors + } + + toString(): string { + const result: string[] = [] + for (const node of this.neighbors) { + if (node.neighbors.length === 0) { + result.push(node.val.toString()) + } else { + const result2: string[] = [] + for (const nodeItem of node.neighbors) { + result2.push(nodeItem.val.toString()) + } + result.push(`[${result2.join(',')}]`) + } + } + return `[${result.join(',')}]` + } +} + +function cloneGraph(node: Node | null): Node | null { + const processedNodes = new Map() + return cloneGraphHelper(node, processedNodes) +} + +function cloneGraphHelper(node: Node | null, processedNodes: Map): Node | null { + if (node === null) { + return null + } + if (processedNodes.has(node)) { + return processedNodes.get(node)! + } + const newNode = new Node(node.val) + processedNodes.set(node, newNode) + for (const neighbor of node.neighbors) { + const clonedNeighbor = cloneGraphHelper(neighbor, processedNodes) + if (clonedNeighbor !== null) { + newNode.neighbors.push(clonedNeighbor) + } + } + return newNode +} + +export { Node, cloneGraph } diff --git a/src/test/ts/g0101_0200/s0130_surrounded_regions/solution.test.ts b/src/test/ts/g0101_0200/s0130_surrounded_regions/solution.test.ts new file mode 100644 index 0000000..13ec8cd --- /dev/null +++ b/src/test/ts/g0101_0200/s0130_surrounded_regions/solution.test.ts @@ -0,0 +1,25 @@ +// tslint:disable:no-magic-numbers +import { solve } from 'src/main/ts/g0101_0200/s0130_surrounded_regions/solution' +import { expect, test } from 'vitest' + +test('solve', () => { + const board: string[][] = [ + ['X', 'X', 'X', 'X'], + ['X', 'O', 'O', 'X'], + ['X', 'X', 'O', 'X'], + ['X', 'O', 'X', 'X'], + ] + solve(board) + expect(board).toEqual([ + ['X', 'X', 'X', 'X'], + ['X', 'X', 'X', 'X'], + ['X', 'X', 'X', 'X'], + ['X', 'O', 'X', 'X'], + ]) +}) + +test('solve', () => { + const board: string[][] = [['X']] + solve(board) + expect(board).toEqual([['X']]) +}) diff --git a/src/test/ts/g0101_0200/s0133_clone_graph/solution.test.ts b/src/test/ts/g0101_0200/s0133_clone_graph/solution.test.ts new file mode 100644 index 0000000..1fd2f9d --- /dev/null +++ b/src/test/ts/g0101_0200/s0133_clone_graph/solution.test.ts @@ -0,0 +1,22 @@ +// tslint:disable:no-magic-numbers +import { Node, cloneGraph } from 'src/main/ts/g0101_0200/s0133_clone_graph/solution' +import { expect, test } from 'vitest' + +test('cloneGraph', () => { + const node1 = new Node(1) + const node2 = new Node(2) + const node3 = new Node(3) + const node4 = new Node(4) + node1.neighbors = [node2, node4] + node2.neighbors = [node1, node3] + node3.neighbors = [node2, node4] + node4.neighbors = [node1, node3] + const clonedNode1 = cloneGraph(node1) + expect(clonedNode1?.toString()).toEqual('[[1,3],[1,3]]') +}) + +test('cloneGraph2', () => { + const node1 = new Node(1) + const clonedNode1 = cloneGraph(node1) + expect(clonedNode1?.toString()).toEqual('[]') +}) From bfd9bd12eca89dbe012577ab1f1ea530351be59d Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Wed, 16 Apr 2025 13:44:45 +0300 Subject: [PATCH 46/49] Added tag LeetCode_75 --- README.md | 196 +++++++++--------- .../solution.ts | 4 +- .../solution.ts | 4 +- .../g0001_0100/s0062_unique_paths/solution.ts | 6 +- .../ts/g0001_0100/s0069_sqrtx/solution.ts | 4 +- .../s0072_edit_distance/solution.ts | 2 +- .../s0088_merge_sorted_array/solution.ts | 4 +- .../solution.ts | 2 +- .../s0136_single_number/solution.ts | 6 +- .../solution.ts | 4 +- .../s0162_find_peak_element/solution.ts | 4 +- .../g0101_0200/s0198_house_robber/solution.ts | 2 +- .../solution.ts | 4 +- .../s0206_reverse_linked_list/solution.ts | 6 +- .../solution.ts | 2 +- .../solution.ts | 6 +- .../solution.ts | 5 +- .../solution.ts | 6 +- .../g0201_0300/s0283_move_zeroes/solution.ts | 6 +- .../s0338_counting_bits/solution.ts | 5 +- .../s0392_is_subsequence/solution.ts | 6 +- .../s0394_decode_string/solution.ts | 5 +- .../s0399_evaluate_division/solution.ts | 3 +- .../g0401_0500/s0437_path_sum_iii/solution.ts | 4 +- .../solution.ts | 2 +- .../s0739_daily_temperatures/solution.ts | 5 +- .../solution.ts | 1 - .../solution.ts | 2 +- 28 files changed, 155 insertions(+), 151 deletions(-) diff --git a/README.md b/README.md index 8445602..f9049d3 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Hard | Array, String, Simulation | 0 | 100.00 +| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Easy | Top_Interview_Questions, Math, Binary_Search | 0 | 100.00 #### Day 5 @@ -163,7 +163,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search | 0 | 100.00 +| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search | 0 | 100.00 #### Day 13 @@ -222,7 +222,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 4 @@ -236,7 +236,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0918 |[Maximum Sum Circular Subarray](src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue, Medium, Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 91.04 +| 0918 |[Maximum Sum Circular Subarray](src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 91.04 #### Day 6 @@ -294,7 +294,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 | 0063 |[Unique Paths II](src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 #### Day 16 @@ -320,9 +320,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers | 0 | 100.00 -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 0 | 100.00 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 #### Day 20 @@ -368,7 +368,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 #### Day 7 Array @@ -389,7 +389,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 #### Day 11 Containers and Libraries @@ -437,7 +437,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 18 | 80.57 +| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, LeetCode_75_Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 18 | 80.57 | 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String | 0 | 100.00 #### Day 7 @@ -659,14 +659,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0205 |[Isomorphic Strings](src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts)| Easy | String, Hash_Table | 3 | 96.02 -| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers | 0 | 100.00 +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 0 | 100.00 #### Day 3 Linked List | | | | | | |-|-|-|-|-|- | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 #### Day 4 Linked List @@ -713,7 +713,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 #### Day 12 Sliding Window/Two Pointer @@ -731,7 +731,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, LeetCode_75_Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 #### Day 15 Heap @@ -782,7 +782,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 1 | 87.16 -| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 3 | 86.41 +| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 3 | 86.41 #### Day 8 Binary Search @@ -814,7 +814,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 #### Day 13 Dynamic Programming @@ -837,14 +837,14 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0100 |[Same Tree](src/main/ts/g0001_0100/s0100_same_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS | 0 | 100.00 #### Day 16 Design | | | | | | |-|-|-|-|-|- | 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 #### Day 17 Interval @@ -876,7 +876,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0007 |[Reverse Integer](src/main/ts/g0001_0100/s0007_reverse_integer/solution.ts)| Medium | Top_Interview_Questions, Math | 53 | 83.14 | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 | 0172 |[Factorial Trailing Zeroes](src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts)| Medium | Top_Interview_Questions, Math | 0 | 100.00 @@ -890,10 +890,10 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0003 |[Longest Substring Without Repeating Characters](src/main/ts/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 3 | 96.91 | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, LeetCode_75_Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting | 4 | 97.99 | 0049 |[Group Anagrams](src/main/ts/g0001_0100/s0049_group_anagrams/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 27 | 78.99 -| 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers | 0 | 100.00 +| 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers, LeetCode_75_Array/String | 0 | 100.00 #### Udemy Binary Search @@ -907,7 +907,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0121 |[Best Time to Buy and Sell Stock](src/main/ts/g0101_0200/s0121_best_time_to_buy_and_sell_stock/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 96.44 -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 | 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String | 0 | 100.00 | 0122 |[Best Time to Buy and Sell Stock II](src/main/ts/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/solution.ts)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 0 | 100.00 @@ -916,7 +916,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0055 |[Jump Game](src/main/ts/g0001_0100/s0055_jump_game/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 | 0041 |[First Missing Positive](src/main/ts/g0001_0100/s0041_first_missing_positive/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 1 | 99.11 | 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 26 | 99.07 @@ -924,7 +924,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers | 0 | 100.00 +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 0 | 100.00 | 0125 |[Valid Palindrome](src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers | 0 | 100.00 | 0026 |[Remove Duplicates from Sorted Array](src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 @@ -961,7 +961,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0024 |[Swap Nodes in Pairs](src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution.ts)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0142 |[Linked List Cycle II](src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 51 | 76.99 | 0141 |[Linked List Cycle](src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 47 | 89.37 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 | 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 65 | 72.36 | 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 3 | 92.85 @@ -980,16 +980,16 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0543 |[Diameter of Binary Tree](src/main/ts/g0501_0600/s0543_diameter_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 1 | 87.16 | 0100 |[Same Tree](src/main/ts/g0001_0100/s0100_same_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0098 |[Validate Binary Search Tree](src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 #### Udemy Trie and Heap | | | | | | |-|-|-|-|-|- -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 #### Udemy Graph @@ -1005,12 +1005,12 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0120 |[Triangle](src/main/ts/g0101_0200/s0120_triangle/solution.ts)| Medium | Array, Dynamic_Programming | 0 | 100.00 | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 | 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 5 | 90.44 #### Udemy Backtracking/Recursion @@ -1020,7 +1020,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 | 0078 |[Subsets](src/main/ts/g0001_0100/s0078_subsets/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 | 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 #### Udemy Bit Manipulation @@ -1029,7 +1029,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 | 0190 |[Reverse Bits](src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 34 | 99.74 -| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 1 | 89.22 +| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 1 | 89.22 #### Udemy Design @@ -1043,7 +1043,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0088 |[Merge Sorted Array](src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0088 |[Merge Sorted Array](src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers | 0 | 100.00 | 0027 |[Remove Element](src/main/ts/g0001_0100/s0027_remove_element/solution.ts)| Easy | Array, Two_Pointers | 0 | 100.00 | 0026 |[Remove Duplicates from Sorted Array](src/main/ts/g0001_0100/s0026_remove_duplicates_from_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 | 0080 |[Remove Duplicates from Sorted Array II](src/main/ts/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/solution.ts)| Medium | Array, Two_Pointers | 40 | 99.63 @@ -1055,7 +1055,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 | 0274 |[H-Index](src/main/ts/g0201_0300/s0274_h_index/solution.ts)| Medium | Array, Sorting, Counting_Sort | 0 | 100.00 | 0380 |[Insert Delete GetRandom O(1)](src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.ts)| Medium | Array, Hash_Table, Math, Design, Randomized | 73 | 82.52 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 | 0134 |[Gas Station](src/main/ts/g0101_0200/s0134_gas_station/solution.ts)| Medium | Top_Interview_Questions, Array, Greedy | 0 | 100.00 | 0135 |[Candy](src/main/ts/g0101_0200/s0135_candy/solution.ts)| Hard | Array, Greedy | 2 | 96.15 | 0042 |[Trapping Rain Water](src/main/ts/g0001_0100/s0042_trapping_rain_water/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 @@ -1063,7 +1063,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0012 |[Integer to Roman](src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts)| Medium | String, Hash_Table, Math | 3 | 93.02 | 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String | 0 | 100.00 | 0014 |[Longest Common Prefix](src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String | 0 | 100.00 -| 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers | 0 | 100.00 +| 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers, LeetCode_75_Array/String | 0 | 100.00 | 0006 |[Zigzag Conversion](src/main/ts/g0001_0100/s0006_zigzag_conversion/solution.ts)| Medium | String | 2 | 99.08 | 0028 |[Implement strStr()](src/main/ts/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 | 0068 |[Text Justification](src/main/ts/g0001_0100/s0068_text_justification/solution.ts)| Hard | Array, String, Simulation | 0 | 100.00 @@ -1073,9 +1073,9 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0125 |[Valid Palindrome](src/main/ts/g0101_0200/s0125_valid_palindrome/solution.ts)| Easy | Top_Interview_Questions, String, Two_Pointers | 0 | 100.00 -| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers | 0 | 100.00 +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 0 | 100.00 | 0167 |[Two Sum II - Input Array Is Sorted](src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts)| Medium | Array, Binary_Search, Two_Pointers | 0 | 100.00 -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 #### Top Interview 150 Sliding Window @@ -1118,7 +1118,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0228 |[Summary Ranges](src/main/ts/g0201_0300/s0228_summary_ranges/solution.ts)| Easy | Array | 0 | 100.00 | 0056 |[Merge Intervals](src/main/ts/g0001_0100/s0056_merge_intervals/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 87.99 | 0057 |[Insert Interval](src/main/ts/g0001_0100/s0057_insert_interval/solution.ts)| Medium | Array | 0 | 100.00 -| 0452 |[Minimum Number of Arrows to Burst Balloons](src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts)| Medium | Array, Sorting, Greedy | 75 | 98.54 +| 0452 |[Minimum Number of Arrows to Burst Balloons](src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts)| Medium | Array, Sorting, Greedy, LeetCode_75_Intervals | 75 | 98.54 #### Top Interview 150 Stack @@ -1150,7 +1150,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 | 0100 |[Same Tree](src/main/ts/g0001_0100/s0100_same_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0226 |[Invert Binary Tree](src/main/ts/g0201_0300/s0226_invert_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 @@ -1163,13 +1163,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11 | 0173 |[Binary Search Tree Iterator](src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 6 | 98.16 | 0222 |[Count Complete Tree Nodes](src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree | 0 | 100.00 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 #### Top Interview 150 Binary Tree BFS | | | | | | |-|-|-|-|-|- -| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS | 0 | 100.00 | 0637 |[Average of Levels in Binary Tree](src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 @@ -1189,7 +1189,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 | 0130 |[Surrounded Regions](src/main/ts/g0101_0200/s0130_surrounded_regions/solution.ts)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 1 | 99.18 | 0133 |[Clone Graph](src/main/ts/g0101_0200/s0133_clone_graph/solution.ts)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph | 48 | 82.94 -| 0399 |[Evaluate Division](src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts)| Medium | Array, Depth_First_Search, Breadth_First_Search, Graph, Union_Find, Shortest_Path | 0 | 100.00 +| 0399 |[Evaluate Division](src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts)| Medium | Array, Depth_First_Search, Breadth_First_Search, Graph, Union_Find, Shortest_Path, LeetCode_75_Graphs/DFS | 0 | 100.00 | 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 | 0210 |[Course Schedule II](src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 2 | 99.76 @@ -1205,7 +1205,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 | 0211 |[Design Add and Search Words Data Structure](src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts)| Medium | String, Depth_First_Search, Design, Trie | 450 | 92.88 | 0212 |[Word Search II](src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie | 62 | 99.46 @@ -1213,7 +1213,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 | 0077 |[Combinations](src/main/ts/g0001_0100/s0077_combinations/solution.ts)| Medium | Backtracking | 46 | 96.14 | 0046 |[Permutations](src/main/ts/g0001_0100/s0046_permutations/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 84.44 | 0039 |[Combination Sum](src/main/ts/g0001_0100/s0039_combination_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 98.17 @@ -1235,7 +1235,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0053 |[Maximum Subarray](src/main/ts/g0001_0100/s0053_maximum_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0918 |[Maximum Sum Circular Subarray](src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue, Medium, Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 91.04 +| 0918 |[Maximum Sum Circular Subarray](src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 91.04 #### Top Interview 150 Binary Search @@ -1243,7 +1243,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. |-|-|-|-|-|- | 0035 |[Search Insert Position](src/main/ts/g0001_0100/s0035_search_insert_position/solution.ts)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 -| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search | 0 | 100.00 +| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search | 0 | 100.00 | 0033 |[Search in Rotated Sorted Array](src/main/ts/g0001_0100/s0033_search_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0034 |[Find First and Last Position of Element in Sorted Array](src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 @@ -1253,7 +1253,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, LeetCode_75_Heap/Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 | 0502 |[IPO](src/main/ts/g0501_0600/s0502_ipo/solution.ts)| Hard | Array, Sorting, Greedy, Heap_Priority_Queue | 193 | 89.19 | 0373 |[Find K Pairs with Smallest Sums](src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts)| Medium | Array, Heap_Priority_Queue | 42 | 85.15 | 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 106 | 92.31 @@ -1265,7 +1265,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0067 |[Add Binary](src/main/ts/g0001_0100/s0067_add_binary/solution.ts)| Easy | String, Math, Bit_Manipulation, Simulation | 0 | 100.00 | 0190 |[Reverse Bits](src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 34 | 99.74 | 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0137 |[Single Number II](src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts)| Medium | Array, Bit_Manipulation | 0 | 100.00 | 0201 |[Bitwise AND of Numbers Range](src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.ts)| Medium | Bit_Manipulation | 2 | 99.12 @@ -1276,7 +1276,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 | 0172 |[Factorial Trailing Zeroes](src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts)| Medium | Top_Interview_Questions, Math | 0 | 100.00 -| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Hard | Array, String, Simulation | 0 | 100.00 +| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Easy | Top_Interview_Questions, Math, Binary_Search | 0 | 100.00 | 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 | 0149 |[Max Points on a Line](src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 9 | 97.18 @@ -1285,7 +1285,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 | 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 @@ -1299,7 +1299,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0063 |[Unique Paths II](src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 | 0005 |[Longest Palindromic Substring](src/main/ts/g0001_0100/s0005_longest_palindromic_substring/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 8 | 99.14 | 0097 |[Interleaving String](src/main/ts/g0001_0100/s0097_interleaving_string/solution.ts)| Medium | String, Dynamic_Programming | 43 | 97.65 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0123 |[Best Time to Buy and Sell Stock III](src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts)| Hard | Array, Dynamic_Programming | 5 | 85.07 | 0188 |[Best Time to Buy and Sell Stock IV](src/main/ts/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/solution.ts)| Hard | Array, Dynamic_Programming | 0 | 100.00 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 @@ -1317,7 +1317,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0001 |[Two Sum](src/main/ts/g0001_0100/s0001_two_sum/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 1 | 89.70 -| 0088 |[Merge Sorted Array](src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0088 |[Merge Sorted Array](src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers | 0 | 100.00 #### Day 3 Array @@ -1355,7 +1355,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 #### Day 9 Stack Queue @@ -1374,7 +1374,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 #### Day 12 Tree @@ -1401,7 +1401,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 @@ -1428,7 +1428,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 | 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 14 | 87.34 #### Day 6 String @@ -1499,7 +1499,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS | 0 | 100.00 #### Day 17 Tree @@ -1512,7 +1512,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 #### Day 19 Graph @@ -1523,7 +1523,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, LeetCode_75_Heap/Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 | 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 7 | 87.13 #### Day 21 Heap Priority Queue @@ -1549,7 +1549,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 | 0167 |[Two Sum II - Input Array Is Sorted](src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts)| Medium | Array, Binary_Search, Two_Pointers | 0 | 100.00 #### Day 4 Two Pointers @@ -1589,7 +1589,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 #### Day 11 Recursion Backtracking @@ -1603,7 +1603,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0120 |[Triangle](src/main/ts/g0101_0200/s0120_triangle/solution.ts)| Medium | Array, Dynamic_Programming | 0 | 100.00 #### Day 13 Bit Manipulation @@ -1617,7 +1617,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0190 |[Reverse Bits](src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 34 | 99.74 -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 ### Algorithm II @@ -1634,7 +1634,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 -| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search | 0 | 100.00 +| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search | 0 | 100.00 #### Day 3 Two Pointers @@ -1647,7 +1647,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 #### Day 5 Sliding Window @@ -1690,7 +1690,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 | 0022 |[Generate Parentheses](src/main/ts/g0001_0100/s0022_generate_parentheses/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 1 | 72.82 | 0079 |[Word Search](src/main/ts/g0001_0100/s0079_word_search/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 243 | 85.30 @@ -1705,7 +1705,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- | 0045 |[Jump Game II](src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 84.27 -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 #### Day 14 Dynamic Programming @@ -1729,13 +1729,13 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 #### Day 18 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 #### Day 19 Bit Manipulation @@ -1760,11 +1760,11 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | # | Title | Difficulty | Tag | Time, ms | Time, % |------|----------------|-------------|-------------|----------|--------- -| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_17_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 -| 0918 |[Maximum Sum Circular Subarray](src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue, Medium, Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue, Dynamic_Programming_I_Day_5, Top_Interview_150_Kadane's_Algorithm | 2 | 91.04 +| 1143 |[Longest Common Subsequence](src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Algorithm_II_Day_17_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Big_O_Time_O(n\*m)_Space_O(n\*m) | 50 | 69.40 +| 0918 |[Maximum Sum Circular Subarray](src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue, Dynamic_Programming_I_Day_5, Top_Interview_150_Kadane's_Algorithm | 2 | 91.04 | 0909 |[Snakes and Ladders](src/main/ts/g0901_1000/s0909_snakes_and_ladders/solution.ts)| Medium | Array, Breadth_First_Search, Matrix, Top_Interview_150_Graph_BFS | 5 | 98.27 | 0763 |[Partition Labels](src/main/ts/g0701_0800/s0763_partition_labels/solution.ts)| Medium | String, Hash_Table, Greedy, Two_Pointers, Data_Structure_II_Day_7_String, Big_O_Time_O(n)_Space_O(1) | 4 | 86.89 -| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, Programming_Skills_II_Day_6, Big_O_Time_O(n)_Space_O(n) | 18 | 80.57 +| 0739 |[Daily Temperatures](src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, LeetCode_75_Monotonic_Stack, Programming_Skills_II_Day_6, Big_O_Time_O(n)_Space_O(n) | 18 | 80.57 | 0647 |[Palindromic Substrings](src/main/ts/g0601_0700/s0647_palindromic_substrings/solution.ts)| Medium | String, Dynamic_Programming, Big_O_Time_O(n^2)_Space_O(n) | 5 | 100.00 | 0637 |[Average of Levels in Binary Tree](src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Top_Interview_150_Binary_Tree_BFS | 0 | 100.00 | 0560 |[Subarray Sum Equals K](src/main/ts/g0501_0600/s0560_subarray_sum_equals_k/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Data_Structure_II_Day_5_Array, Big_O_Time_O(n)_Space_O(n) | 14 | 87.34 @@ -1772,33 +1772,33 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0530 |[Minimum Absolute Difference in BST](src/main/ts/g0501_0600/s0530_minimum_absolute_difference_in_bst/solution.ts)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Top_Interview_150_Binary_Search_Tree | 0 | 100.00 | 0502 |[IPO](src/main/ts/g0501_0600/s0502_ipo/solution.ts)| Hard | Array, Sorting, Greedy, Heap_Priority_Queue, Top_Interview_150_Heap | 193 | 89.19 | 0494 |[Target Sum](src/main/ts/g0401_0500/s0494_target_sum/solution.ts)| Medium | Array, Dynamic_Programming, Backtracking, Big_O_Time_O(n\*(sum+s))_Space_O(n\*(sum+s)) | 24 | 83.43 -| 0452 |[Minimum Number of Arrows to Burst Balloons](src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts)| Medium | Array, Sorting, Greedy, Top_Interview_150_Intervals | 75 | 98.54 +| 0452 |[Minimum Number of Arrows to Burst Balloons](src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts)| Medium | Array, Sorting, Greedy, LeetCode_75_Intervals, Top_Interview_150_Intervals | 75 | 98.54 | 0438 |[Find All Anagrams in a String](src/main/ts/g0401_0500/s0438_find_all_anagrams_in_a_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Programming_Skills_II_Day_12, Level_1_Day_12_Sliding_Window/Two_Pointer, Big_O_Time_O(n+m)_Space_O(1) | 8 | 97.80 -| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, Level_2_Day_7_Tree, Big_O_Time_O(n)_Space_O(n) | 3 | 86.41 +| 0437 |[Path Sum III](src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Level_2_Day_7_Tree, Big_O_Time_O(n)_Space_O(n) | 3 | 86.41 | 0433 |[Minimum Genetic Mutation](src/main/ts/g0401_0500/s0433_minimum_genetic_mutation/solution.ts)| Medium | String, Hash_Table, Breadth_First_Search, Graph_Theory_I_Day_12_Breadth_First_Search, Top_Interview_150_Graph_BFS | 0 | 100.00 | 0427 |[Construct Quad Tree](src/main/ts/g0401_0500/s0427_construct_quad_tree/solution.ts)| Medium | Array, Tree, Matrix, Divide_and_Conquer, Top_Interview_150_Divide_and_Conquer | 51 | 96.23 | 0416 |[Partition Equal Subset Sum](src/main/ts/g0401_0500/s0416_partition_equal_subset_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Level_2_Day_13_Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 33 | 93.24 -| 0399 |[Evaluate Division](src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts)| Medium | Array, Depth_First_Search, Breadth_First_Search, Graph, Union_Find, Shortest_Path, Top_Interview_150_Graph_General | 0 | 100.00 -| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Level_1_Day_14_Stack, Udemy_Strings, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers, Dynamic_Programming_I_Day_19, Level_1_Day_2_String, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers | 0 | 100.00 +| 0399 |[Evaluate Division](src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts)| Medium | Array, Depth_First_Search, Breadth_First_Search, Graph, Union_Find, Shortest_Path, LeetCode_75_Graphs/DFS, Top_Interview_150_Graph_General | 0 | 100.00 +| 0394 |[Decode String](src/main/ts/g0301_0400/s0394_decode_string/solution.ts)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, LeetCode_75_Stack, Level_1_Day_14_Stack, Udemy_Strings, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0392 |[Is Subsequence](src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers, Dynamic_Programming_I_Day_19, Level_1_Day_2_String, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers | 0 | 100.00 | 0383 |[Ransom Note](src/main/ts/g0301_0400/s0383_ransom_note/solution.ts)| Easy | String, Hash_Table, Counting, Data_Structure_I_Day_6_String, Top_Interview_150_Hashmap | 4 | 97.40 | 0380 |[Insert Delete GetRandom O(1)](src/main/ts/g0301_0400/s0380_insert_delete_getrandom_o1/solution.ts)| Medium | Array, Hash_Table, Math, Design, Randomized, Programming_Skills_II_Day_20, Top_Interview_150_Array/String | 73 | 82.52 | 0373 |[Find K Pairs with Smallest Sums](src/main/ts/g0301_0400/s0373_find_k_pairs_with_smallest_sums/solution.ts)| Medium | Array, Heap_Priority_Queue, Top_Interview_150_Heap | 42 | 85.15 | 0347 |[Top K Frequent Elements](src/main/ts/g0301_0400/s0347_top_k_frequent_elements/solution.ts)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Data_Structure_II_Day_20_Heap_Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(k) | 7 | 87.13 -| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, Udemy_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 1 | 89.22 +| 0338 |[Counting Bits](src/main/ts/g0301_0400/s0338_counting_bits/solution.ts)| Easy | Dynamic_Programming, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Udemy_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 1 | 89.22 | 0322 |[Coin Change](src/main/ts/g0301_0400/s0322_coin_change/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_20, Level_2_Day_12_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(m\*n)_Space_O(amount) | 27 | 89.42 | 0300 |[Longest Increasing Subsequence](src/main/ts/g0201_0300/s0300_longest_increasing_subsequence/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Algorithm_II_Day_16_Dynamic_Programming, Binary_Search_II_Day_3, Dynamic_Programming_I_Day_18, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n\*log_n)_Space_O(n) | 6 | 84.68 | 0295 |[Find Median from Data Stream](src/main/ts/g0201_0300/s0295_find_median_from_data_stream/solution.ts)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Top_Interview_150_Heap, Big_O_Time_O(n\*log_n)_Space_O(n) | 106 | 92.31 | 0290 |[Word Pattern](src/main/ts/g0201_0300/s0290_word_pattern/solution.ts)| Easy | String, Hash_Table, Data_Structure_II_Day_7_String, Top_Interview_150_Hashmap | 0 | 100.00 | 0289 |[Game of Life](src/main/ts/g0201_0300/s0289_game_of_life/solution.ts)| Medium | Array, Matrix, Simulation, Top_Interview_150_Matrix | 0 | 100.00 | 0287 |[Find the Duplicate Number](src/main/ts/g0201_0300/s0287_find_the_duplicate_number/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Binary_Search_II_Day_5, Big_O_Time_O(n)_Space_O(n) | 5 | 88.65 -| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Programming_Skills_I_Day_6_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 +| 0283 |[Move Zeroes](src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Programming_Skills_I_Day_6_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 1 | 82.86 | 0274 |[H-Index](src/main/ts/g0201_0300/s0274_h_index/solution.ts)| Medium | Array, Sorting, Counting_Sort, Top_Interview_150_Array/String | 0 | 100.00 | 0242 |[Valid Anagram](src/main/ts/g0201_0300/s0242_valid_anagram/solution.ts)| Easy | String, Hash_Table, Sorting, Data_Structure_I_Day_6_String, Programming_Skills_I_Day_11_Containers_and_Libraries, Udemy_Strings, Top_Interview_150_Hashmap | 4 | 97.99 | 0240 |[Search a 2D Matrix II](src/main/ts/g0201_0300/s0240_search_a_2d_matrix_ii/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Data_Structure_II_Day_4_Array, Binary_Search_II_Day_8, Big_O_Time_O(n+m)_Space_O(1) | 42 | 94.61 | 0239 |[Sliding Window Maximum](src/main/ts/g0201_0300/s0239_sliding_window_maximum/solution.ts)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Udemy_Arrays, Big_O_Time_O(n\*k)_Space_O(n+k) | 26 | 99.07 -| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, Data_Structure_II_Day_5_Array, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_18_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 +| 0238 |[Product of Array Except Self](src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Data_Structure_II_Day_5_Array, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 3 | 92.81 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Data_Structure_II_Day_18_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97 | 0234 |[Palindrome Linked List](src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Level_2_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(n)_Space_O(1) | 3 | 92.85 | 0230 |[Kth Smallest Element in a BST](src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Data_Structure_II_Day_17_Tree, Level_2_Day_9_Binary_Search_Tree, Top_Interview_150_Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0228 |[Summary Ranges](src/main/ts/g0201_0300/s0228_summary_ranges/solution.ts)| Easy | Array, Top_Interview_150_Intervals | 0 | 100.00 @@ -1807,20 +1807,20 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0222 |[Count Complete Tree Nodes](src/main/ts/g0201_0300/s0222_count_complete_tree_nodes/solution.ts)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree, Binary_Search_II_Day_10, Top_Interview_150_Binary_Tree_General | 0 | 100.00 | 0221 |[Maximal Square](src/main/ts/g0201_0300/s0221_maximal_square/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 18 | 59.02 | 0219 |[Contains Duplicate II](src/main/ts/g0201_0300/s0219_contains_duplicate_ii/solution.ts)| Easy | Array, Hash_Table, Sliding_Window, Top_Interview_150_Hashmap | 17 | 79.29 -| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, Data_Structure_II_Day_20_Heap_Priority_Queue, Top_Interview_150_Heap, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 +| 0215 |[Kth Largest Element in an Array](src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, LeetCode_75_Heap/Priority_Queue, Data_Structure_II_Day_20_Heap_Priority_Queue, Top_Interview_150_Heap, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 4 | 99.64 | 0212 |[Word Search II](src/main/ts/g0201_0300/s0212_word_search_ii/solution.ts)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie, Top_Interview_150_Trie | 62 | 99.46 | 0211 |[Design Add and Search Words Data Structure](src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts)| Medium | String, Depth_First_Search, Design, Trie, Top_Interview_150_Trie | 450 | 92.88 | 0210 |[Course Schedule II](src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Level_2_Day_11_Graph/BFS/DFS, Top_Interview_150_Graph_General | 2 | 99.76 | 0209 |[Minimum Size Subarray Sum](src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window, Algorithm_II_Day_5_Sliding_Window, Binary_Search_II_Day_1, Top_Interview_150_Sliding_Window | 2 | 88.11 -| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, Level_2_Day_16_Design, Udemy_Trie_and_Heap, Top_Interview_150_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 +| 0208 |[Implement Trie (Prefix Tree)](src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Level_2_Day_16_Design, Udemy_Trie_and_Heap, Top_Interview_150_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 48 | 63.95 | 0207 |[Course Schedule](src/main/ts/g0201_0300/s0207_course_schedule/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Top_Interview_150_Graph_General, Big_O_Time_O(N)_Space_O(N) | 11 | 81.08 -| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_8_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0206 |[Reverse Linked List](src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Data_Structure_I_Day_8_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 | 0205 |[Isomorphic Strings](src/main/ts/g0201_0300/s0205_isomorphic_strings/solution.ts)| Easy | String, Hash_Table, Level_1_Day_2_String, Top_Interview_150_Hashmap | 3 | 96.02 | 0202 |[Happy Number](src/main/ts/g0201_0300/s0202_happy_number/solution.ts)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers, Algorithm_II_Day_21_Others, Programming_Skills_I_Day_4_Loop, Level_2_Day_1_Implementation/Simulation, Top_Interview_150_Hashmap | 0 | 100.00 | 0201 |[Bitwise AND of Numbers Range](src/main/ts/g0201_0300/s0201_bitwise_and_of_numbers_range/solution.ts)| Medium | Bit_Manipulation, Algorithm_II_Day_19_Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 2 | 99.12 | 0200 |[Number of Islands](src/main/ts/g0101_0200/s0200_number_of_islands/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search, Graph_Theory_I_Day_1_Matrix_Related_Problems, Level_1_Day_9_Graph/BFS/DFS, Udemy_Graph, Top_Interview_150_Graph_General, Big_O_Time_O(M\*N)_Space_O(M\*N) | 57 | 93.94 -| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_16_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_BFS | 0 | 100.00 -| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_3, Level_2_Day_12_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0199 |[Binary Tree Right Side View](src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS, Data_Structure_II_Day_16_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_BFS | 0 | 100.00 +| 0198 |[House Robber](src/main/ts/g0101_0200/s0198_house_robber/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_3, Level_2_Day_12_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0191 |[Number of 1 Bits](src/main/ts/g0101_0200/s0191_number_of_1_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Algorithm_I_Day_13_Bit_Manipulation, Programming_Skills_I_Day_2_Operator, Udemy_Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 0 | 100.00 | 0190 |[Reverse Bits](src/main/ts/g0101_0200/s0190_reverse_bits/solution.ts)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 34 | 99.74 | 0189 |[Rotate Array](src/main/ts/g0101_0200/s0189_rotate_array/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Algorithm_I_Day_2_Two_Pointers, Udemy_Arrays, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 1 | 86.17 @@ -1829,12 +1829,12 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0172 |[Factorial Trailing Zeroes](src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts)| Medium | Top_Interview_Questions, Math, Udemy_Integers, Top_Interview_150_Math | 0 | 100.00 | 0169 |[Majority Element](src/main/ts/g0101_0200/s0169_majority_element/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Data_Structure_II_Day_1_Array, Udemy_Famous_Algorithm, Top_Interview_150_Array/String, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0167 |[Two Sum II - Input Array Is Sorted](src/main/ts/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/solution.ts)| Medium | Array, Binary_Search, Two_Pointers, Algorithm_I_Day_3_Two_Pointers, Binary_Search_I_Day_7, Top_Interview_150_Two_Pointers | 0 | 100.00 -| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_II_Day_12, Top_Interview_150_Binary_Search | 0 | 100.00 +| 0162 |[Find Peak Element](src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_II_Day_12, Top_Interview_150_Binary_Search | 0 | 100.00 | 0160 |[Intersection of Two Linked Lists](src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Data_Structure_II_Day_11_Linked_List, Udemy_Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 65 | 72.36 | 0155 |[Min Stack](src/main/ts/g0101_0200/s0155_min_stack/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Data_Structure_II_Day_14_Stack_Queue, Programming_Skills_II_Day_18, Level_2_Day_16_Design, Udemy_Design, Top_Interview_150_Stack, Big_O_Time_O(1)_Space_O(N) | 5 | 99.10 | 0153 |[Find Minimum in Rotated Sorted Array](src/main/ts/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_II_Day_2_Binary_Search, Binary_Search_I_Day_12, Udemy_Binary_Search, Top_Interview_150_Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 | 0152 |[Maximum Product Subarray](src/main/ts/g0101_0200/s0152_maximum_product_subarray/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Dynamic_Programming_I_Day_6, Level_2_Day_13_Dynamic_Programming, Udemy_Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -| 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers, Udemy_Strings, Top_Interview_150_Array/String | 0 | 100.00 +| 0151 |[Reverse Words in a String](src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts)| Medium | String, Two_Pointers, LeetCode_75_Array/String, Udemy_Strings, Top_Interview_150_Array/String | 0 | 100.00 | 0150 |[Evaluate Reverse Polish Notation](src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts)| Medium | Top_Interview_Questions, Array, Math, Stack, Programming_Skills_II_Day_3, Top_Interview_150_Stack | 1 | 97.48 | 0149 |[Max Points on a Line](src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry, Algorithm_II_Day_21_Others, Top_Interview_150_Math | 9 | 97.18 | 0148 |[Sort List](src/main/ts/g0101_0200/s0148_sort_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Level_2_Day_4_Linked_List, Top_Interview_150_Divide_and_Conquer, Big_O_Time_O(log(N))_Space_O(log(N)) | 36 | 44.94 @@ -1844,7 +1844,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0139 |[Word Break](src/main/ts/g0101_0200/s0139_word_break/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Algorithm_II_Day_15_Dynamic_Programming, Dynamic_Programming_I_Day_9, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 4 | 76.41 | 0138 |[Copy List with Random Pointer](src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Programming_Skills_II_Day_14, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(N)_Space_O(N) | 49 | 72.42 | 0137 |[Single Number II](src/main/ts/g0101_0200/s0137_single_number_ii/solution.ts)| Medium | Array, Bit_Manipulation, Top_Interview_150_Bit_Manipulation | 0 | 100.00 -| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Data_Structure_II_Day_1_Array, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Integers, Top_Interview_150_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 +| 0136 |[Single Number](src/main/ts/g0101_0200/s0136_single_number/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Data_Structure_II_Day_1_Array, Algorithm_I_Day_14_Bit_Manipulation, Udemy_Integers, Top_Interview_150_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 78.27 | 0135 |[Candy](src/main/ts/g0101_0200/s0135_candy/solution.ts)| Hard | Array, Greedy, Top_Interview_150_Array/String | 2 | 96.15 | 0134 |[Gas Station](src/main/ts/g0101_0200/s0134_gas_station/solution.ts)| Medium | Top_Interview_Questions, Array, Greedy, Top_Interview_150_Array/String | 0 | 100.00 | 0133 |[Clone Graph](src/main/ts/g0101_0200/s0133_clone_graph/solution.ts)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph, Udemy_Graph, Top_Interview_150_Graph_General | 48 | 82.94 @@ -1865,7 +1865,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0108 |[Convert Sorted Array to Binary Search Tree](src/main/ts/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/solution.ts)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Level_2_Day_9_Binary_Search_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Divide_and_Conquer | 0 | 100.00 | 0106 |[Construct Binary Tree from Inorder and Postorder Traversal](src/main/ts/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/solution.ts)| Medium | Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Top_Interview_150_Binary_Tree_General | 1 | 98.78 | 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Data_Structure_II_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 2 | 93.38 -| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Programming_Skills_I_Day_10_Linked_List_and_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0104 |[Maximum Depth of Binary Tree](src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Data_Structure_I_Day_11_Tree, Programming_Skills_I_Day_10_Linked_List_and_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 | 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/ts/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/solution.ts)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_II_Day_15_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS | 0 | 100.00 | 0102 |[Binary Tree Level Order Traversal](src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_1_Day_6_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_BFS, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 | 0101 |[Symmetric Tree](src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Data_Structure_I_Day_11_Tree, Level_2_Day_15_Tree, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 @@ -1875,7 +1875,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0096 |[Unique Binary Search Trees](src/main/ts/g0001_0100/s0096_unique_binary_search_trees/solution.ts)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Dynamic_Programming_I_Day_11, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0094 |[Binary Tree Inorder Traversal](src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Data_Structure_I_Day_10_Tree, Udemy_Tree_Stack_Queue, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0092 |[Reverse Linked List II](src/main/ts/g0001_0100/s0092_reverse_linked_list_ii/solution.ts)| Medium | Linked_List, Top_Interview_150_Linked_List | 0 | 100.00 -| 0088 |[Merge Sorted Array](src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts)| Medium | Two_Pointers, Linked_List, Top_Interview_150_Linked_List | 0 | 100.00 +| 0088 |[Merge Sorted Array](src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_I_Day_2_Array, Top_Interview_150_Array/String | 0 | 100.00 | 0086 |[Partition List](src/main/ts/g0001_0100/s0086_partition_list/solution.ts)| Medium | Two_Pointers, Linked_List, Top_Interview_150_Linked_List | 0 | 100.00 | 0084 |[Largest Rectangle in Histogram](src/main/ts/g0001_0100/s0084_largest_rectangle_in_histogram/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Stack, Monotonic_Stack, Big_O_Time_O(n_log_n)_Space_O(log_n) | 15 | 72.81 | 0082 |[Remove Duplicates from Sorted List II](src/main/ts/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/solution.ts)| Medium | Two_Pointers, Linked_List, Data_Structure_II_Day_11_Linked_List, Algorithm_II_Day_3_Two_Pointers, Top_Interview_150_Linked_List | 0 | 100.00 @@ -1887,16 +1887,16 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0075 |[Sort Colors](src/main/ts/g0001_0100/s0075_sort_colors/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_2_Array, Udemy_Arrays, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 | 0074 |[Search a 2D Matrix](src/main/ts/g0001_0100/s0074_search_a_2d_matrix/solution.ts)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Data_Structure_I_Day_5_Array, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_8, Level_2_Day_8_Binary_Search, Udemy_2D_Arrays/Matrix, Top_Interview_150_Binary_Search, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 | 0073 |[Set Matrix Zeroes](src/main/ts/g0001_0100/s0073_set_matrix_zeroes/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Udemy_2D_Arrays/Matrix, Top_Interview_150_Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 4 | 50.63 -| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 +| 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0071 |[Simplify Path](src/main/ts/g0001_0100/s0071_simplify_path/solution.ts)| Medium | String, Stack, Top_Interview_150_Stack | 0 | 100.00 | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_2, Level_1_Day_10_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Hard | Array, String, Simulation, Top_Interview_150_Array/String | 0 | 100.00 +| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Easy | Top_Interview_Questions, Math, Binary_Search, Binary_Search_I_Day_4, Top_Interview_150_Math | 0 | 100.00 | 0068 |[Text Justification](src/main/ts/g0001_0100/s0068_text_justification/solution.ts)| Hard | Array, String, Simulation, Top_Interview_150_Array/String | 0 | 100.00 | 0067 |[Add Binary](src/main/ts/g0001_0100/s0067_add_binary/solution.ts)| Easy | String, Math, Bit_Manipulation, Simulation, Programming_Skills_II_Day_5, Top_Interview_150_Bit_Manipulation | 0 | 100.00 | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math, Programming_Skills_II_Day_3, Udemy_Arrays, Top_Interview_150_Math | 0 | 100.00 | 0064 |[Minimum Path Sum](src/main/ts/g0001_0100/s0064_minimum_path_sum/solution.ts)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_16, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(m\*n)_Space_O(m\*n) | 4 | 70.73 | 0063 |[Unique Paths II](src/main/ts/g0001_0100/s0063_unique_paths_ii/solution.ts)| Medium | Array, Dynamic_Programming, Matrix, Dynamic_Programming_I_Day_15, Top_Interview_150_Multidimensional_DP | 0 | 100.00 -| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_15, Level_1_Day_11_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 0062 |[Unique Paths](src/main/ts/g0001_0100/s0062_unique_paths/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_15, Level_1_Day_11_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 | 0061 |[Rotate List](src/main/ts/g0001_0100/s0061_rotate_list/solution.ts)| Medium | Two_Pointers, Linked_List, Programming_Skills_II_Day_16, Udemy_Linked_List, Top_Interview_150_Linked_List | 0 | 100.00 | 0058 |[Length of Last Word](src/main/ts/g0001_0100/s0058_length_of_last_word/solution.ts)| Easy | String, Programming_Skills_II_Day_6, Udemy_Arrays, Top_Interview_150_Array/String | 0 | 100.00 | 0057 |[Insert Interval](src/main/ts/g0001_0100/s0057_insert_interval/solution.ts)| Medium | Array, Level_2_Day_17_Interval, Top_Interview_150_Intervals | 0 | 100.00 @@ -1931,12 +1931,12 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0021 |[Merge Two Sorted Lists](src/main/ts/g0001_0100/s0021_merge_two_sorted_lists/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_7_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(m+n)_Space_O(m+n) | 1 | 51.21 | 0020 |[Valid Parentheses](src/main/ts/g0001_0100/s0020_valid_parentheses/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Data_Structure_I_Day_9_Stack_Queue, Udemy_Strings, Top_Interview_150_Stack, Big_O_Time_O(n)_Space_O(n) | 1 | 86.85 | 0019 |[Remove Nth Node From End of List](src/main/ts/g0001_0100/s0019_remove_nth_node_from_end_of_list/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Algorithm_I_Day_5_Two_Pointers, Level_2_Day_3_Linked_List, Top_Interview_150_Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 -| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0017 |[Letter Combinations of a Phone Number](src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion, Top_Interview_150_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 | 0015 |[3Sum](src/main/ts/g0001_0100/s0015_3sum/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_1_Array, Algorithm_II_Day_3_Two_Pointers, Udemy_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 30 | 91.56 | 0014 |[Longest Common Prefix](src/main/ts/g0001_0100/s0014_longest_common_prefix/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Level_2_Day_2_String, Udemy_Strings, Top_Interview_150_Array/String | 0 | 100.00 | 0013 |[Roman to Integer](src/main/ts/g0001_0100/s0013_roman_to_integer/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Math, Top_Interview_150_Array/String | 3 | 94.58 | 0012 |[Integer to Roman](src/main/ts/g0001_0100/s0012_integer_to_roman/solution.ts)| Medium | String, Hash_Table, Math, Top_Interview_150_Array/String | 3 | 93.02 -| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Algorithm_II_Day_4_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 +| 0011 |[Container With Most Water](src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, LeetCode_75_Two_Pointers, Algorithm_II_Day_4_Two_Pointers, Top_Interview_150_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 80.13 | 0010 |[Regular Expression Matching](src/main/ts/g0001_0100/s0010_regular_expression_matching/solution.ts)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Udemy_Dynamic_Programming, Big_O_Time_O(m\*n)_Space_O(m\*n) | 5 | 90.44 | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math, Udemy_Integers, Top_Interview_150_Math | 3 | 99.14 | 0008 |[String to Integer (atoi)](src/main/ts/g0001_0100/s0008_string_to_integer_atoi/solution.ts)| Medium | Top_Interview_Questions, String | 1 | 90.14 diff --git a/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts b/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts index dca9c4c..29a6a7a 100644 --- a/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts +++ b/src/main/ts/g0001_0100/s0011_container_with_most_water/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Greedy #Two_Pointers -// #Algorithm_II_Day_4_Two_Pointers #Top_Interview_150_Two_Pointers #Big_O_Time_O(n)_Space_O(1) -// #2025_03_22_Time_2_ms_(80.13%)_Space_65.63_MB_(10.65%) +// #LeetCode_75_Two_Pointers #Algorithm_II_Day_4_Two_Pointers #Top_Interview_150_Two_Pointers +// #Big_O_Time_O(n)_Space_O(1) #2025_03_22_Time_2_ms_(80.13%)_Space_65.63_MB_(10.65%) function maxArea(height: number[]): number { let maxArea = -1 diff --git a/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts b/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts index 32a7978..7bf7035 100644 --- a/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts +++ b/src/main/ts/g0001_0100/s0017_letter_combinations_of_a_phone_number/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Backtracking -// #Algorithm_II_Day_11_Recursion_Backtracking #Udemy_Backtracking/Recursion -// #Top_Interview_150_Backtracking #Big_O_Time_O(4^n)_Space_O(n) +// #LeetCode_75_Backtracking #Algorithm_II_Day_11_Recursion_Backtracking +// #Udemy_Backtracking/Recursion #Top_Interview_150_Backtracking #Big_O_Time_O(4^n)_Space_O(n) // #2025_03_22_Time_0_ms_(100.00%)_Space_56.27_MB_(8.55%) function letterCombinations(digits: string): string[] { diff --git a/src/main/ts/g0001_0100/s0062_unique_paths/solution.ts b/src/main/ts/g0001_0100/s0062_unique_paths/solution.ts index 3d650eb..6a301dd 100644 --- a/src/main/ts/g0001_0100/s0062_unique_paths/solution.ts +++ b/src/main/ts/g0001_0100/s0062_unique_paths/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Dynamic_Programming #Math -// #Combinatorics #Algorithm_II_Day_13_Dynamic_Programming #Dynamic_Programming_I_Day_15 -// #Level_1_Day_11_Dynamic_Programming #Big_O_Time_O(m*n)_Space_O(m*n) -// #2025_03_23_Time_0_ms_(100.00%)_Space_55.15_MB_(43.54%) +// #Combinatorics #LeetCode_75_DP/Multidimensional #Algorithm_II_Day_13_Dynamic_Programming +// #Dynamic_Programming_I_Day_15 #Level_1_Day_11_Dynamic_Programming +// #Big_O_Time_O(m*n)_Space_O(m*n) #2025_03_23_Time_0_ms_(100.00%)_Space_55.15_MB_(43.54%) function uniquePaths(m: number, n: number): number { let aboveRow = Array(n).fill(1) diff --git a/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts b/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts index 4d29882..fa84fd5 100644 --- a/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts +++ b/src/main/ts/g0001_0100/s0069_sqrtx/solution.ts @@ -1,5 +1,5 @@ -// #Hard #Array #String #Simulation #Top_Interview_150_Array/String -// #2025_04_05_Time_0_ms_(100.00%)_Space_55.70_MB_(38.14%) +// #Easy #Top_Interview_Questions #Math #Binary_Search #Binary_Search_I_Day_4 +// #Top_Interview_150_Math #2025_04_16_Time_1_ms_(74.84%)_Space_57.85_MB_(56.21%) function mySqrt(x: number): number { let low = 1 diff --git a/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts b/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts index d4d3d49..5530272 100644 --- a/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts +++ b/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts @@ -1,4 +1,4 @@ -// #Medium #Top_100_Liked_Questions #String #Dynamic_Programming +// #Medium #Top_100_Liked_Questions #String #Dynamic_Programming #LeetCode_75_DP/Multidimensional // #Algorithm_II_Day_18_Dynamic_Programming #Dynamic_Programming_I_Day_19 // #Udemy_Dynamic_Programming #Top_Interview_150_Multidimensional_DP #Big_O_Time_O(n^2)_Space_O(n2) // #2025_03_23_Time_6_ms_(93.83%)_Space_61.09_MB_(45.68%) diff --git a/src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts b/src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts index 559a255..dbc8551 100644 --- a/src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts +++ b/src/main/ts/g0001_0100/s0088_merge_sorted_array/solution.ts @@ -1,5 +1,5 @@ -// #Medium #Two_Pointers #Linked_List #Top_Interview_150_Linked_List -// #2025_04_05_Time_0_ms_(100.00%)_Space_58.16_MB_(62.07%) +// #Easy #Top_Interview_Questions #Array #Sorting #Two_Pointers #Data_Structure_I_Day_2_Array +// #Top_Interview_150_Array/String #2025_04_05_Time_0_ms_(100.00%)_Space_58.16_MB_(62.07%) /** * Do not return anything, modify nums1 in-place instead. diff --git a/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts b/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts index 5a8f158..3501548 100644 --- a/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts +++ b/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts @@ -1,5 +1,5 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Breadth_First_Search -// #Tree #Binary_Tree #Data_Structure_I_Day_11_Tree +// #Tree #Binary_Tree #LeetCode_75_Binary_Tree/DFS #Data_Structure_I_Day_11_Tree // #Programming_Skills_I_Day_10_Linked_List_and_Tree #Udemy_Tree_Stack_Queue // #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(N)_Space_O(H) // #2025_03_26_Time_0_ms_(100.00%)_Space_59.10_MB_(43.48%) diff --git a/src/main/ts/g0101_0200/s0136_single_number/solution.ts b/src/main/ts/g0101_0200/s0136_single_number/solution.ts index 6e15ea3..886fb23 100644 --- a/src/main/ts/g0101_0200/s0136_single_number/solution.ts +++ b/src/main/ts/g0101_0200/s0136_single_number/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Bit_Manipulation -// #Data_Structure_II_Day_1_Array #Algorithm_I_Day_14_Bit_Manipulation #Udemy_Integers -// #Top_Interview_150_Bit_Manipulation #Big_O_Time_O(N)_Space_O(1) -// #2025_03_26_Time_1_ms_(78.27%)_Space_58.44_MB_(41.08%) +// #LeetCode_75_Bit_Manipulation #Data_Structure_II_Day_1_Array +// #Algorithm_I_Day_14_Bit_Manipulation #Udemy_Integers #Top_Interview_150_Bit_Manipulation +// #Big_O_Time_O(N)_Space_O(1) #2025_03_26_Time_1_ms_(78.27%)_Space_58.44_MB_(41.08%) function singleNumber(nums: number[]): number { let ans = 0 diff --git a/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts b/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts index 8c4215f..b0faaf3 100644 --- a/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts +++ b/src/main/ts/g0101_0200/s0151_reverse_words_in_a_string/solution.ts @@ -1,5 +1,5 @@ -// #Medium #String #Two_Pointers #Udemy_Strings #Top_Interview_150_Array/String -// #2025_04_08_Time_0_ms_(100.00%)_Space_57.70_MB_(48.75%) +// #Medium #String #Two_Pointers #LeetCode_75_Array/String #Udemy_Strings +// #Top_Interview_150_Array/String #2025_04_08_Time_0_ms_(100.00%)_Space_57.70_MB_(48.75%) function reverseWords(s: string): string { return s diff --git a/src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts b/src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts index d79d342..1df4ccd 100644 --- a/src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts +++ b/src/main/ts/g0101_0200/s0162_find_peak_element/solution.ts @@ -1,5 +1,5 @@ -// #Medium #Top_Interview_Questions #Array #Binary_Search #Algorithm_II_Day_2_Binary_Search -// #Binary_Search_II_Day_12 #Top_Interview_150_Binary_Search +// #Medium #Top_Interview_Questions #Array #Binary_Search #LeetCode_75_Binary_Search +// #Algorithm_II_Day_2_Binary_Search #Binary_Search_II_Day_12 #Top_Interview_150_Binary_Search // #2025_04_08_Time_0_ms_(100.00%)_Space_55.40_MB_(60.85%) function findPeakElement(nums: number[]): number { diff --git a/src/main/ts/g0101_0200/s0198_house_robber/solution.ts b/src/main/ts/g0101_0200/s0198_house_robber/solution.ts index 5340eb8..11753e6 100644 --- a/src/main/ts/g0101_0200/s0198_house_robber/solution.ts +++ b/src/main/ts/g0101_0200/s0198_house_robber/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming -// #Algorithm_I_Day_12_Dynamic_Programming #Dynamic_Programming_I_Day_3 +// #LeetCode_75_DP/1D #Algorithm_I_Day_12_Dynamic_Programming #Dynamic_Programming_I_Day_3 // #Level_2_Day_12_Dynamic_Programming #Udemy_Dynamic_Programming #Top_Interview_150_1D_DP // #Big_O_Time_O(n)_Space_O(n) #2025_03_26_Time_0_ms_(100.00%)_Space_55.74_MB_(28.06%) diff --git a/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts b/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts index 7011329..e45a4d9 100644 --- a/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts +++ b/src/main/ts/g0101_0200/s0199_binary_tree_right_side_view/solution.ts @@ -1,6 +1,6 @@ // #Medium #Top_100_Liked_Questions #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree -// #Data_Structure_II_Day_16_Tree #Level_2_Day_15_Tree #Top_Interview_150_Binary_Tree_BFS -// #2025_04_10_Time_0_ms_(100.00%)_Space_56.98_MB_(73.71%) +// #LeetCode_75_Binary_Tree/BFS #Data_Structure_II_Day_16_Tree #Level_2_Day_15_Tree +// #Top_Interview_150_Binary_Tree_BFS #2025_04_10_Time_0_ms_(100.00%)_Space_56.98_MB_(73.71%) import { TreeNode } from '../../com_github_leetcode/treenode' diff --git a/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts b/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts index 5f0eb57..096db78 100644 --- a/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts +++ b/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts @@ -1,7 +1,7 @@ // #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Linked_List #Recursion -// #Data_Structure_I_Day_8_Linked_List #Algorithm_I_Day_10_Recursion_Backtracking -// #Level_1_Day_3_Linked_List #Udemy_Linked_List #Big_O_Time_O(N)_Space_O(1) -// #2025_03_26_Time_0_ms_(100.00%)_Space_58.92_MB_(16.01%) +// #LeetCode_75_LinkedList #Data_Structure_I_Day_8_Linked_List +// #Algorithm_I_Day_10_Recursion_Backtracking #Level_1_Day_3_Linked_List #Udemy_Linked_List +// #Big_O_Time_O(N)_Space_O(1) #2025_03_26_Time_0_ms_(100.00%)_Space_58.92_MB_(16.01%) import { ListNode } from '../../com_github_leetcode/listnode' diff --git a/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts b/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts index 53a753e..f490b91 100644 --- a/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts +++ b/src/main/ts/g0201_0300/s0208_implement_trie_prefix_tree/solution.ts @@ -1,5 +1,5 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Design #Trie -// #Level_2_Day_16_Design #Udemy_Trie_and_Heap #Top_Interview_150_Trie +// #LeetCode_75_Trie #Level_2_Day_16_Design #Udemy_Trie_and_Heap #Top_Interview_150_Trie // #Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) // #2025_03_26_Time_48_ms_(63.95%)_Space_81.97_MB_(12.22%) diff --git a/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts b/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts index ab5f7da..cb0d0ff 100644 --- a/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts +++ b/src/main/ts/g0201_0300/s0215_kth_largest_element_in_an_array/solution.ts @@ -1,7 +1,7 @@ // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting #Heap_Priority_Queue -// #Divide_and_Conquer #Quickselect #Data_Structure_II_Day_20_Heap_Priority_Queue -// #Top_Interview_150_Heap #Big_O_Time_O(n*log(n))_Space_O(log(n)) -// #2025_03_26_Time_4_ms_(99.64%)_Space_66.28_MB_(62.13%) +// #Divide_and_Conquer #Quickselect #LeetCode_75_Heap/Priority_Queue +// #Data_Structure_II_Day_20_Heap_Priority_Queue #Top_Interview_150_Heap +// #Big_O_Time_O(n*log(n))_Space_O(log(n)) #2025_03_26_Time_4_ms_(99.64%)_Space_66.28_MB_(62.13%) function findKthLargest(nums: number[], k: number): number { const countingLen = 2e4 + 1 diff --git a/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts b/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts index 7a50797..3fe559a 100644 --- a/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts +++ b/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts @@ -1,6 +1,7 @@ // #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree -// #Data_Structure_II_Day_18_Tree #Udemy_Tree_Stack_Queue #Top_Interview_150_Binary_Tree_General -// #Big_O_Time_O(n)_Space_O(n) #2025_03_28_Time_61_ms_(75.97%)_Space_65.98_MB_(36.62%) +// #LeetCode_75_Binary_Tree/DFS #Data_Structure_II_Day_18_Tree #Udemy_Tree_Stack_Queue +// #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(n)_Space_O(n) +// #2025_03_28_Time_61_ms_(75.97%)_Space_65.98_MB_(36.62%) /* * Definition for a binary tree node. diff --git a/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts b/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts index 6ab8a94..b91f58a 100644 --- a/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts +++ b/src/main/ts/g0201_0300/s0238_product_of_array_except_self/solution.ts @@ -1,6 +1,6 @@ -// #Medium #Top_100_Liked_Questions #Array #Prefix_Sum #Data_Structure_II_Day_5_Array #Udemy_Arrays -// #Top_Interview_150_Array/String #Big_O_Time_O(n^2)_Space_O(n) -// #2025_03_28_Time_3_ms_(92.81%)_Space_70.08_MB_(42.74%) +// #Medium #Top_100_Liked_Questions #Array #Prefix_Sum #LeetCode_75_Array/String +// #Data_Structure_II_Day_5_Array #Udemy_Arrays #Top_Interview_150_Array/String +// #Big_O_Time_O(n^2)_Space_O(n) #2025_03_28_Time_3_ms_(92.81%)_Space_70.08_MB_(42.74%) function productExceptSelf(nums: number[]): number[] { const n = nums.length diff --git a/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts b/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts index 774c180..236324e 100644 --- a/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts +++ b/src/main/ts/g0201_0300/s0283_move_zeroes/solution.ts @@ -1,6 +1,6 @@ -// #Easy #Top_100_Liked_Questions #Array #Two_Pointers #Algorithm_I_Day_3_Two_Pointers -// #Programming_Skills_I_Day_6_Array #Udemy_Arrays #Big_O_Time_O(n)_Space_O(1) -// #2025_03_28_Time_1_ms_(82.86%)_Space_62.16_MB_(10.71%) +// #Easy #Top_100_Liked_Questions #Array #Two_Pointers #LeetCode_75_Two_Pointers +// #Algorithm_I_Day_3_Two_Pointers #Programming_Skills_I_Day_6_Array #Udemy_Arrays +// #Big_O_Time_O(n)_Space_O(1) #2025_03_28_Time_1_ms_(82.86%)_Space_62.16_MB_(10.71%) /* Do not return anything, modify nums in-place instead. diff --git a/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts b/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts index 29b4577..dac0ca4 100644 --- a/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts +++ b/src/main/ts/g0301_0400/s0338_counting_bits/solution.ts @@ -1,5 +1,6 @@ -// #Easy #Dynamic_Programming #Bit_Manipulation #Udemy_Bit_Manipulation -// #Big_O_Time_O(num)_Space_O(num) #2025_03_28_Time_1_ms_(89.22%)_Space_62.26_MB_(53.31%) +// #Easy #Dynamic_Programming #Bit_Manipulation #LeetCode_75_Bit_Manipulation +// #Udemy_Bit_Manipulation #Big_O_Time_O(num)_Space_O(num) +// #2025_03_28_Time_1_ms_(89.22%)_Space_62.26_MB_(53.31%) function countBits(n: number): number[] { const bits: number[] = [0] diff --git a/src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts b/src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts index be39263..ae62cb8 100644 --- a/src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts +++ b/src/main/ts/g0301_0400/s0392_is_subsequence/solution.ts @@ -1,6 +1,6 @@ -// #Easy #String #Dynamic_Programming #Two_Pointers #Dynamic_Programming_I_Day_19 -// #Level_1_Day_2_String #Udemy_Two_Pointers #Top_Interview_150_Two_Pointers -// #2025_04_14_Time_0_ms_(100.00%)_Space_56.51_MB_(36.22%) +// #Easy #String #Dynamic_Programming #Two_Pointers #LeetCode_75_Two_Pointers +// #Dynamic_Programming_I_Day_19 #Level_1_Day_2_String #Udemy_Two_Pointers +// #Top_Interview_150_Two_Pointers #2025_04_14_Time_0_ms_(100.00%)_Space_56.51_MB_(36.22%) function isSubsequence(s: string, t: string): boolean { let i = 0 diff --git a/src/main/ts/g0301_0400/s0394_decode_string/solution.ts b/src/main/ts/g0301_0400/s0394_decode_string/solution.ts index e031a64..812511a 100644 --- a/src/main/ts/g0301_0400/s0394_decode_string/solution.ts +++ b/src/main/ts/g0301_0400/s0394_decode_string/solution.ts @@ -1,5 +1,6 @@ -// #Medium #Top_100_Liked_Questions #String #Stack #Recursion #Level_1_Day_14_Stack #Udemy_Strings -// #Big_O_Time_O(n)_Space_O(n) #2025_03_28_Time_0_ms_(100.00%)_Space_55.70_MB_(34.63%) +// #Medium #Top_100_Liked_Questions #String #Stack #Recursion #LeetCode_75_Stack +// #Level_1_Day_14_Stack #Udemy_Strings #Big_O_Time_O(n)_Space_O(n) +// #2025_03_28_Time_0_ms_(100.00%)_Space_55.70_MB_(34.63%) function decodeString(s: string): string { let stack: string[] = [] diff --git a/src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts b/src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts index 1c9fa7e..d401761 100644 --- a/src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts +++ b/src/main/ts/g0301_0400/s0399_evaluate_division/solution.ts @@ -1,5 +1,6 @@ // #Medium #Array #Depth_First_Search #Breadth_First_Search #Graph #Union_Find #Shortest_Path -// #Top_Interview_150_Graph_General #2025_04_16_Time_0_ms_(100.00%)_Space_54.98_MB_(77.31%) +// #LeetCode_75_Graphs/DFS #Top_Interview_150_Graph_General +// #2025_04_16_Time_0_ms_(100.00%)_Space_54.98_MB_(77.31%) type MapType = Map type RateType = Map diff --git a/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts b/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts index 77843eb..bfea432 100644 --- a/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts +++ b/src/main/ts/g0401_0500/s0437_path_sum_iii/solution.ts @@ -1,5 +1,5 @@ -// #Medium #Depth_First_Search #Tree #Binary_Tree #Level_2_Day_7_Tree #Big_O_Time_O(n)_Space_O(n) -// #2025_03_28_Time_3_ms_(86.41%)_Space_61.43_MB_(43.21%) +// #Medium #Depth_First_Search #Tree #Binary_Tree #LeetCode_75_Binary_Tree/DFS #Level_2_Day_7_Tree +// #Big_O_Time_O(n)_Space_O(n) #2025_03_28_Time_3_ms_(86.41%)_Space_61.43_MB_(43.21%) function pathSum(root: TreeNode | null, targetSum: number): number { let count = 0 diff --git a/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts b/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts index 208ddb1..8e7b241 100644 --- a/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts +++ b/src/main/ts/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/solution.ts @@ -1,4 +1,4 @@ -// #Medium #Array #Sorting #Greedy #Top_Interview_150_Intervals +// #Medium #Array #Sorting #Greedy #LeetCode_75_Intervals #Top_Interview_150_Intervals // #2025_04_15_Time_75_ms_(98.54%)_Space_79.44_MB_(62.20%) function findMinArrowShots(points: number[][]): number { diff --git a/src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts b/src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts index e1bbbcc..65fee87 100644 --- a/src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts +++ b/src/main/ts/g0701_0800/s0739_daily_temperatures/solution.ts @@ -1,5 +1,6 @@ -// #Medium #Top_100_Liked_Questions #Array #Stack #Monotonic_Stack #Programming_Skills_II_Day_6 -// #Big_O_Time_O(n)_Space_O(n) #2025_03_28_Time_18_ms_(80.57%)_Space_78.12_MB_(62.08%) +// #Medium #Top_100_Liked_Questions #Array #Stack #Monotonic_Stack #LeetCode_75_Monotonic_Stack +// #Programming_Skills_II_Day_6 #Big_O_Time_O(n)_Space_O(n) +// #2025_03_28_Time_18_ms_(80.57%)_Space_78.12_MB_(62.08%) function dailyTemperatures(temperatures: number[]): number[] { let stack: number[] = [] diff --git a/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts b/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts index 8c446f8..8fadd4a 100644 --- a/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts +++ b/src/main/ts/g0901_1000/s0918_maximum_sum_circular_subarray/solution.ts @@ -1,5 +1,4 @@ // #Medium #Array #Dynamic_Programming #Divide_and_Conquer #Queue #Monotonic_Queue -// #Medium #Array #Dynamic_Programming #Divide_and_Conquer #Queue #Monotonic_Queue // #Dynamic_Programming_I_Day_5 #Top_Interview_150_Kadane's_Algorithm // #2025_04_15_Time_2_ms_(91.04%)_Space_61.54_MB_(85.07%) diff --git a/src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts b/src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts index bfdf6bf..003fafd 100644 --- a/src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts +++ b/src/main/ts/g1101_1200/s1143_longest_common_subsequence/solution.ts @@ -1,4 +1,4 @@ -// #Medium #Top_100_Liked_Questions #String #Dynamic_Programming +// #Medium #Top_100_Liked_Questions #String #Dynamic_Programming #LeetCode_75_DP/Multidimensional // #Algorithm_II_Day_17_Dynamic_Programming #Dynamic_Programming_I_Day_19 // #Udemy_Dynamic_Programming #Big_O_Time_O(n*m)_Space_O(n*m) // #2025_03_28_Time_50_ms_(69.40%)_Space_85.72_MB_(16.94%) From f5e5230f7530196a7e768665610bc6652545de75 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Wed, 16 Apr 2025 13:47:57 +0300 Subject: [PATCH 47/49] Updated readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f9049d3..9d47fa4 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | | | | | | |-|-|-|-|-|- -| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Easy | Top_Interview_Questions, Math, Binary_Search | 0 | 100.00 +| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Easy | Top_Interview_Questions, Math, Binary_Search | 1 | 74.84 #### Day 5 @@ -1276,7 +1276,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0009 |[Palindrome Number](src/main/ts/g0001_0100/s0009_palindrome_number/solution.ts)| Easy | Math | 3 | 99.14 | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 | 0172 |[Factorial Trailing Zeroes](src/main/ts/g0101_0200/s0172_factorial_trailing_zeroes/solution.ts)| Medium | Top_Interview_Questions, Math | 0 | 100.00 -| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Easy | Top_Interview_Questions, Math, Binary_Search | 0 | 100.00 +| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Easy | Top_Interview_Questions, Math, Binary_Search | 1 | 74.84 | 0050 |[Pow(x, n)](src/main/ts/g0001_0100/s0050_powx_n/solution.ts)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 | 0149 |[Max Points on a Line](src/main/ts/g0101_0200/s0149_max_points_on_a_line/solution.ts)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 9 | 97.18 @@ -1890,7 +1890,7 @@ TypeScript-based LeetCode algorithm problem solutions, regularly updated. | 0072 |[Edit Distance](src/main/ts/g0001_0100/s0072_edit_distance/solution.ts)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming, Top_Interview_150_Multidimensional_DP, Big_O_Time_O(n^2)_Space_O(n2) | 6 | 93.83 | 0071 |[Simplify Path](src/main/ts/g0001_0100/s0071_simplify_path/solution.ts)| Medium | String, Stack, Top_Interview_150_Stack | 0 | 100.00 | 0070 |[Climbing Stairs](src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Algorithm_I_Day_12_Dynamic_Programming, Dynamic_Programming_I_Day_2, Level_1_Day_10_Dynamic_Programming, Udemy_Dynamic_Programming, Top_Interview_150_1D_DP, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Easy | Top_Interview_Questions, Math, Binary_Search, Binary_Search_I_Day_4, Top_Interview_150_Math | 0 | 100.00 +| 0069 |[Sqrt(x)](src/main/ts/g0001_0100/s0069_sqrtx/solution.ts)| Easy | Top_Interview_Questions, Math, Binary_Search, Binary_Search_I_Day_4, Top_Interview_150_Math | 1 | 74.84 | 0068 |[Text Justification](src/main/ts/g0001_0100/s0068_text_justification/solution.ts)| Hard | Array, String, Simulation, Top_Interview_150_Array/String | 0 | 100.00 | 0067 |[Add Binary](src/main/ts/g0001_0100/s0067_add_binary/solution.ts)| Easy | String, Math, Bit_Manipulation, Simulation, Programming_Skills_II_Day_5, Top_Interview_150_Bit_Manipulation | 0 | 100.00 | 0066 |[Plus One](src/main/ts/g0001_0100/s0066_plus_one/solution.ts)| Easy | Top_Interview_Questions, Array, Math, Programming_Skills_II_Day_3, Udemy_Arrays, Top_Interview_150_Math | 0 | 100.00 From ca22e0fcbc2f0f5a7a5a98dd69ca836d0f620b3e Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sun, 20 Apr 2025 13:40:19 +0300 Subject: [PATCH 48/49] Improved tasks --- .../s0002_add_two_numbers/solution.ts | 2 +- .../s0023_merge_k_sorted_lists/solution.ts | 2 +- .../solution.ts | 6 ----- .../s0031_next_permutation/solution.ts | 7 +++--- .../solution.ts | 2 -- .../g0001_0100/s0036_valid_sudoku/solution.ts | 3 --- .../s0039_combination_sum/solution.ts | 1 - .../s0054_spiral_matrix/solution.ts | 5 ---- .../s0070_climbing_stairs/solution.ts | 12 +++++++--- .../s0072_edit_distance/solution.ts | 4 +++- .../ts/g0001_0100/s0078_subsets/solution.ts | 4 +++- .../g0001_0100/s0079_word_search/solution.ts | 24 +++++++++---------- .../solution.ts | 10 +++++--- .../solution.ts | 12 +++++++--- .../s0101_symmetric_tree/solution.ts | 14 +++++++---- .../solution.ts | 14 +++++++---- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../solution.ts | 2 +- .../g0101_0200/s0139_word_break/solution.ts | 8 +++++-- .../s0141_linked_list_cycle/solution.ts | 6 +++-- .../s0142_linked_list_cycle_ii/solution.ts | 6 +++-- .../ts/g0101_0200/s0148_sort_list/solution.ts | 6 +++-- .../solution.ts | 12 ++++++---- .../solution.ts | 2 +- .../s0206_reverse_linked_list/solution.ts | 2 +- .../s0207_course_schedule/solution.ts | 1 - .../solution.ts | 1 - .../s0210_course_schedule_ii/solution.ts | 4 +++- .../solution.ts | 2 -- .../solution.ts | 2 +- .../s0234_palindrome_linked_list/solution.ts | 2 +- .../solution.ts | 2 +- .../g0201_0300/s0289_game_of_life/solution.ts | 2 -- .../solution.ts | 1 - 37 files changed, 106 insertions(+), 85 deletions(-) diff --git a/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts b/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts index eee9f4e..ae37aea 100644 --- a/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts +++ b/src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts @@ -5,7 +5,7 @@ import { ListNode } from '../../com_github_leetcode/listnode' -/* +/** * Definition for singly-linked list. * class ListNode { * val: number diff --git a/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts b/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts index 13212d9..49e2d65 100644 --- a/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts +++ b/src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts @@ -4,7 +4,7 @@ import { ListNode } from '../../com_github_leetcode/listnode' -/* +/** * Definition for singly-linked list. * class ListNode { * val: number diff --git a/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts b/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts index 2470100..069a034 100644 --- a/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts +++ b/src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts @@ -6,32 +6,26 @@ function findSubstring(s: string, words: string[]): number[] { let n1 = words[0].length let n2 = s.length let map1 = new Map() - for (let ch of words) { map1.set(ch, (map1.get(ch) ?? 0) + 1) } - for (let i = 0; i < n1; i++) { let left = i let j = i let c = 0 let map2 = new Map() - while (j + n1 <= n2) { let word1 = s.substring(j, j + n1) j += n1 - if (map1.has(word1)) { map2.set(word1, (map2.get(word1) ?? 0) + 1) c++ - while ((map2.get(word1) ?? 0) > (map1.get(word1) ?? 0)) { let word2 = s.substring(left, left + n1) map2.set(word2, (map2.get(word2) ?? 0) - 1) left += n1 c-- } - if (c === words.length) { ans.push(left) } diff --git a/src/main/ts/g0001_0100/s0031_next_permutation/solution.ts b/src/main/ts/g0001_0100/s0031_next_permutation/solution.ts index ca349e0..3723344 100644 --- a/src/main/ts/g0001_0100/s0031_next_permutation/solution.ts +++ b/src/main/ts/g0001_0100/s0031_next_permutation/solution.ts @@ -6,15 +6,14 @@ */ function nextPermutation(nums: number[]): void { let swapperIndex: number | null = null - for (let ind = nums.length - 1; ind >= 0 && swapperIndex == null; ind--) { if (nums[ind] > nums[ind - 1]) { swapperIndex = ind - 1 } } - - if (swapperIndex == null) nums.sort((a, b) => a - b) - else { + if (swapperIndex == null) { + nums.sort((a, b) => a - b) + } else { nums.splice(swapperIndex + 1, nums.length, ...nums.slice(swapperIndex + 1, nums.length).sort((a, b) => a - b)) let indToBringForward = swapperIndex + 1 while (nums[indToBringForward] <= nums[swapperIndex]) ++indToBringForward diff --git a/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts b/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts index 11c348d..49c99a2 100644 --- a/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts +++ b/src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts @@ -9,7 +9,6 @@ function searchRange(nums: number[], target: number): number[] { //NOSONAR let left2 = left1 let right1 = nums.length - 1 let right2 = right1 - while (left1 <= right1 || left2 <= right2) { if (left1 <= right1) { let mid1 = Math.floor((left1 + right1) / 2) @@ -22,7 +21,6 @@ function searchRange(nums: number[], target: number): number[] { //NOSONAR right1 = mid1 - 1 } } - if (left2 <= right2) { let mid2 = Math.floor((left2 + right2) / 2) if (nums[mid2] == target) { diff --git a/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts b/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts index 315eee3..2ca47a4 100644 --- a/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts +++ b/src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts @@ -5,7 +5,6 @@ function isValidSudoku(board: string[][]): boolean { let rowSet: number[] = new Array(9).fill(0) let colSet: number[] = new Array(9).fill(0) let boxSet: number[] = new Array(9).fill(0) - for (let i = 0; i < 9; i++) { for (let j = 0; j < 9; j++) { if (board[i][j] === '.') { @@ -13,11 +12,9 @@ function isValidSudoku(board: string[][]): boolean { } let val = board[i][j].charCodeAt(0) - '0'.charCodeAt(0) let boxIndex = Math.floor(i / 3) * 3 + Math.floor(j / 3) - if (rowSet[i] & (1 << val) || colSet[j] & (1 << val) || boxSet[boxIndex] & (1 << val)) { return false } - rowSet[i] |= 1 << val colSet[j] |= 1 << val boxSet[boxIndex] |= 1 << val diff --git a/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts b/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts index 0b8c183..c518fdf 100644 --- a/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts +++ b/src/main/ts/g0001_0100/s0039_combination_sum/solution.ts @@ -6,7 +6,6 @@ function combinationSum(candidates: number[], target: number): number[][] { const result: number[][] = [] const path: number[] = [] - const comFunct = (index: number, sum: number) => { if (sum === target) { result.push([...path]) diff --git a/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts b/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts index 3cfb163..48a76ae 100644 --- a/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts +++ b/src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts @@ -8,29 +8,24 @@ function spiralOrder(matrix: number[][]): number[] { c = 0 let bigR = matrix.length - 1 let bigC = matrix[0].length - 1 - while (r <= bigR && c <= bigC) { for (let i = c; i <= bigC; i++) { result.push(matrix[r][i]) } r++ - for (let i = r; i <= bigR; i++) { result.push(matrix[i][bigC]) } bigC-- - for (let i = bigC; i >= c && r <= bigR; i--) { result.push(matrix[bigR][i]) } bigR-- - for (let i = bigR; i >= r && c <= bigC; i--) { result.push(matrix[i][c]) } c++ } - return result } diff --git a/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts b/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts index c6110a2..305252f 100644 --- a/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts +++ b/src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts @@ -4,9 +4,15 @@ // #Big_O_Time_O(n)_Space_O(n) #2025_03_23_Time_0_ms_(100.00%)_Space_56.23_MB_(5.15%) function climbStairs(n: number, memo: Record = {}): number { - if (n in memo) return memo[n] - if (n === 0) return 1 - if (n < 0) return 0 + if (n in memo) { + return memo[n] + } + if (n === 0) { + return 1 + } + if (n < 0) { + return 0 + } memo[n] = climbStairs(n - 1, memo) + climbStairs(n - 2, memo) return memo[n] } diff --git a/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts b/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts index 5530272..e6c7463 100644 --- a/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts +++ b/src/main/ts/g0001_0100/s0072_edit_distance/solution.ts @@ -8,7 +8,9 @@ function minDistance(word1: string, word2: string): number { const l1 = word1.length const l2 = word2.length const dfs = (w1: number, w2: number): number => { - if (memo[w1][w2] != undefined) return memo[w1][w2] + if (memo[w1][w2] != undefined) { + return memo[w1][w2] + } if (w1 == l1 && w2 == l2) { memo[w1][w2] = 0 return 0 diff --git a/src/main/ts/g0001_0100/s0078_subsets/solution.ts b/src/main/ts/g0001_0100/s0078_subsets/solution.ts index 8e55897..5a9c361 100644 --- a/src/main/ts/g0001_0100/s0078_subsets/solution.ts +++ b/src/main/ts/g0001_0100/s0078_subsets/solution.ts @@ -4,7 +4,9 @@ function subsets(nums: number[]): number[][] { const sets: number[][] = [[]] - for (const num of nums) sets.push(...sets.map((set) => [...set, num])) + for (const num of nums) { + sets.push(...sets.map((set) => [...set, num])) + } return sets } diff --git a/src/main/ts/g0001_0100/s0079_word_search/solution.ts b/src/main/ts/g0001_0100/s0079_word_search/solution.ts index f06c1a9..e6f40c4 100644 --- a/src/main/ts/g0001_0100/s0079_word_search/solution.ts +++ b/src/main/ts/g0001_0100/s0079_word_search/solution.ts @@ -12,7 +12,6 @@ function exist(board: string[][], word: string): boolean { if (loop(marks, board, i, j, word, 0)) return true } } - return ret } @@ -31,28 +30,29 @@ function loop(marks: boolean[][], board: string[][], i: number, j: number, word: if (i < 0 || j < 0 || i >= board.length || j >= board[i].length || marks[i][j]) { return false } - if (board[i][j] !== word.charAt(index)) { return false } else if (index === word.length - 1) { return true } - marks[i][j] = true index++ - let r = loop(marks, board, i - 1, j, word, index) - if (r) return true - + if (r) { + return true + } r = loop(marks, board, i + 1, j, word, index) - if (r) return true - + if (r) { + return true + } r = loop(marks, board, i, j - 1, word, index) - if (r) return true - + if (r) { + return true + } r = loop(marks, board, i, j + 1, word, index) - if (r) return true - + if (r) { + return true + } marks[i][j] = false return false } diff --git a/src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts b/src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts index f0b4f6e..7f88854 100644 --- a/src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts +++ b/src/main/ts/g0001_0100/s0094_binary_tree_inorder_traversal/solution.ts @@ -4,7 +4,7 @@ import { TreeNode } from '../../com_github_leetcode/treenode' -/* +/** * Definition for a binary tree node. * class TreeNode { * val: number @@ -18,8 +18,12 @@ import { TreeNode } from '../../com_github_leetcode/treenode' * } */ function inorderTraversal(root: TreeNode | null): number[] { - if (!root) return [] - if (!root.val) return [] + if (!root) { + return [] + } + if (!root.val) { + return [] + } const result: number[] = [] function traverse(node: TreeNode, arr: number[]) { if (node.left) { diff --git a/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts b/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts index 3405944..93a58d7 100644 --- a/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts +++ b/src/main/ts/g0001_0100/s0098_validate_binary_search_tree/solution.ts @@ -19,9 +19,15 @@ import { TreeNode } from '../../com_github_leetcode/treenode' * } */ function dfs(node: TreeNode | null, lowerBound: number, upperBound: number): boolean { - if (!node) return true - if (node.val <= lowerBound) return false - if (node.val >= upperBound) return false + if (!node) { + return true + } + if (node.val <= lowerBound) { + return false + } + if (node.val >= upperBound) { + return false + } return dfs(node.left, lowerBound, node.val) && dfs(node.right, node.val, upperBound) } diff --git a/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts b/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts index 830ea3a..ebb3065 100644 --- a/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts +++ b/src/main/ts/g0101_0200/s0101_symmetric_tree/solution.ts @@ -5,7 +5,7 @@ import { TreeNode } from '../../com_github_leetcode/treenode' -/* +/** * Definition for a binary tree node. * class TreeNode { * val: number @@ -19,14 +19,20 @@ import { TreeNode } from '../../com_github_leetcode/treenode' * } */ function isSymmetric(root: TreeNode | null): boolean { - if (!root.left && !root.right) return true + if (!root.left && !root.right) { + return true + } const queue: [TreeNode, TreeNode][] = [[root.left, root.right]] while (queue.length > 0) { let qLen: number = queue.length while (qLen-- > 0) { const [leftNode, rightNode] = queue.shift() - if (!leftNode && !rightNode) continue - if (!leftNode || !rightNode || leftNode.val != rightNode.val) return false + if (!leftNode && !rightNode) { + continue + } + if (!leftNode || !rightNode || leftNode.val != rightNode.val) { + return false + } queue.push([leftNode.left, rightNode.right]) queue.push([leftNode.right, rightNode.left]) } diff --git a/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts b/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts index 1764202..b981158 100644 --- a/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts +++ b/src/main/ts/g0101_0200/s0102_binary_tree_level_order_traversal/solution.ts @@ -5,7 +5,7 @@ import { TreeNode } from '../../com_github_leetcode/treenode' -/* +/** * Definition for a binary tree node. * class TreeNode { * val: number @@ -19,7 +19,9 @@ import { TreeNode } from '../../com_github_leetcode/treenode' * } */ function levelOrder(root: TreeNode | null): number[][] { - if (root == null) return [] + if (root == null) { + return [] + } let queue = [root] let result = [] while (queue.length != 0) { @@ -28,8 +30,12 @@ function levelOrder(root: TreeNode | null): number[][] { while (length > 0) { let node = queue.shift() subResult.push(node.val) - if (node.left != null) queue.push(node.left) - if (node.right != null) queue.push(node.right) + if (node.left != null) { + queue.push(node.left) + } + if (node.right != null) { + queue.push(node.right) + } length-- } result.push(subResult) diff --git a/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts b/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts index 3501548..7d59ff9 100644 --- a/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts +++ b/src/main/ts/g0101_0200/s0104_maximum_depth_of_binary_tree/solution.ts @@ -6,7 +6,7 @@ import { TreeNode } from '../../com_github_leetcode/treenode' -/* +/** * Definition for a binary tree node. * class TreeNode { * val: number diff --git a/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts b/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts index 0c7ac6a..c99fb0e 100644 --- a/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts +++ b/src/main/ts/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/solution.ts @@ -4,7 +4,7 @@ import { TreeNode } from '../../com_github_leetcode/treenode' -/* +/** * Definition for a binary tree node. * class TreeNode { * val: number diff --git a/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts b/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts index c33e52b..5315d0e 100644 --- a/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts +++ b/src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts @@ -4,7 +4,7 @@ import { TreeNode } from '../../com_github_leetcode/treenode' -/* +/** * Definition for a binary tree node. * class TreeNode { * val: number diff --git a/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts b/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts index eb6995d..887e1d2 100644 --- a/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts +++ b/src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts @@ -4,7 +4,7 @@ import { TreeNode } from '../../com_github_leetcode/treenode' -/* +/** * Definition for a binary tree node. * class TreeNode { * val: number diff --git a/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts b/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts index 27c0059..0e9542c 100644 --- a/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts +++ b/src/main/ts/g0101_0200/s0138_copy_list_with_random_pointer/solution.ts @@ -4,7 +4,7 @@ import { Node } from '../../com_github_leetcode/node' -/* +/** * Definition for Node. * class Node { * val: number diff --git a/src/main/ts/g0101_0200/s0139_word_break/solution.ts b/src/main/ts/g0101_0200/s0139_word_break/solution.ts index 67b914f..9088d59 100644 --- a/src/main/ts/g0101_0200/s0139_word_break/solution.ts +++ b/src/main/ts/g0101_0200/s0139_word_break/solution.ts @@ -5,14 +5,18 @@ function wordBreak(s: string, wordDict: string[]): boolean { const dp: boolean[] = [] - for (let i = 0; i <= s.length; i++) dp.push(false) + for (let i = 0; i <= s.length; i++) { + dp.push(false) + } dp[s.length] = true for (let j = s.length - 1; j >= 0; j--) { for (const word of wordDict) { if (s.slice(j, j + word.length) === word && j + word.length <= s.length) { dp[j] = dp[j + word.length] } - if (dp[j]) break + if (dp[j]) { + break + } } } return dp[0] diff --git a/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts b/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts index 282483e..f2d1459 100644 --- a/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts +++ b/src/main/ts/g0101_0200/s0141_linked_list_cycle/solution.ts @@ -4,7 +4,7 @@ import { ListNode } from '../../com_github_leetcode/listnode' -/* +/** * Definition for singly-linked list. * class ListNode { * val: number @@ -20,7 +20,9 @@ function hasCycle(head: ListNode | null): boolean { while (fast?.next) { head = head.next fast = fast.next.next - if (head === fast) return true + if (head === fast) { + return true + } } return false } diff --git a/src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts b/src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts index 76b39d2..481a1b1 100644 --- a/src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts +++ b/src/main/ts/g0101_0200/s0142_linked_list_cycle_ii/solution.ts @@ -4,7 +4,7 @@ import { ListNode } from '../../com_github_leetcode/listnode' -/* +/** * Definition for singly-linked list. * class ListNode { * val: number @@ -18,7 +18,9 @@ import { ListNode } from '../../com_github_leetcode/listnode' function detectCycle(head: ListNode | null): ListNode | null { const set = new Set() while (head) { - if (set.has(head)) return head + if (set.has(head)) { + return head + } set.add(head) head = head.next } diff --git a/src/main/ts/g0101_0200/s0148_sort_list/solution.ts b/src/main/ts/g0101_0200/s0148_sort_list/solution.ts index a2a5988..7506769 100644 --- a/src/main/ts/g0101_0200/s0148_sort_list/solution.ts +++ b/src/main/ts/g0101_0200/s0148_sort_list/solution.ts @@ -4,7 +4,7 @@ import { ListNode } from '../../com_github_leetcode/listnode' -/* +/** * Definition for singly-linked list. * class ListNode { * val: number @@ -17,7 +17,9 @@ import { ListNode } from '../../com_github_leetcode/listnode' */ function sortList(head: ListNode | null): ListNode | null { - if (!head) return null + if (!head) { + return null + } let array = [] while (head) { array.push([head, head.val]) diff --git a/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts b/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts index 1e2ceda..2ac3ed8 100644 --- a/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts +++ b/src/main/ts/g0101_0200/s0150_evaluate_reverse_polish_notation/solution.ts @@ -8,11 +8,13 @@ function evalRPN(tokens: string[]): number { if (isOperator(token)) { const right = numberStack.pop() as number const left = numberStack.pop() as number - - if (token === '+') numberStack.push(left + right) - else if (token === '-') numberStack.push(left - right) - else if (token === '*') numberStack.push(left * right) - else if (token === '/') { + if (token === '+') { + numberStack.push(left + right) + } else if (token === '-') { + numberStack.push(left - right) + } else if (token === '*') { + numberStack.push(left * right) + } else if (token === '/') { const result = left / right numberStack.push(result < 0 ? Math.ceil(result) : Math.floor(result)) } diff --git a/src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts b/src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts index 18faf5d..632dcbc 100644 --- a/src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts +++ b/src/main/ts/g0101_0200/s0160_intersection_of_two_linked_lists/solution.ts @@ -4,7 +4,7 @@ import { ListNode } from '../../com_github_leetcode/listnode' -/* +/** * Definition for singly-linked list. * class ListNode { * val: number diff --git a/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts b/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts index 096db78..12b2ca0 100644 --- a/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts +++ b/src/main/ts/g0201_0300/s0206_reverse_linked_list/solution.ts @@ -5,7 +5,7 @@ import { ListNode } from '../../com_github_leetcode/listnode' -/* +/** * Definition for singly-linked list. * class ListNode { * val: number diff --git a/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts b/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts index 7ca00b4..1b23ff3 100644 --- a/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts +++ b/src/main/ts/g0201_0300/s0207_course_schedule/solution.ts @@ -26,7 +26,6 @@ function hasCycle(adj: number[][], node: number, colors: number[]): boolean { if (colors[nei] === GRAY) { return true } - if (colors[nei] === WHITE && hasCycle(adj, nei, colors)) { return true } diff --git a/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts b/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts index 90c234f..296d41a 100644 --- a/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts +++ b/src/main/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.ts @@ -20,7 +20,6 @@ function minSubArrayLen(target: number, nums: number[]): number { } min = Math.min(min, j - i + 1) } - j++ } return min === Number.MAX_SAFE_INTEGER ? 0 : min diff --git a/src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts b/src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts index 1d77c43..919dd15 100644 --- a/src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts +++ b/src/main/ts/g0201_0300/s0210_course_schedule_ii/solution.ts @@ -4,7 +4,9 @@ function findOrder(numCourses: number, prerequisites: number[][]): number[] { let sortedOrder: number[] = [] - if (numCourses < 0) return sortedOrder + if (numCourses < 0) { + return sortedOrder + } let inDegree = new Array(numCourses).fill(0), graph = new Array(numCourses).fill(0).map(() => new Array()), source = new Array() diff --git a/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts b/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts index cfa6011..60d11ae 100644 --- a/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts +++ b/src/main/ts/g0201_0300/s0211_design_add_and_search_words_data_structure/solution.ts @@ -31,7 +31,6 @@ class WordDictionary { } const currentLetter = word[index] index += 1 - if (currentLetter === '.') { return Object.keys(subtree).some((letter) => searchSubtree(word, index, subtree[letter] as TrieNode)) } else { @@ -42,7 +41,6 @@ class WordDictionary { } } } - return searchSubtree(word, 0, this.root) } } diff --git a/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts b/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts index 4bb3fc1..bc18228 100644 --- a/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts +++ b/src/main/ts/g0201_0300/s0230_kth_smallest_element_in_a_bst/solution.ts @@ -3,7 +3,7 @@ // #Top_Interview_150_Binary_Search_Tree #Big_O_Time_O(n)_Space_O(n) // #2025_03_28_Time_0_ms_(100.00%)_Space_61.27_MB_(52.69%) -/* +/** * Definition for a binary tree node. * class TreeNode { * val: number diff --git a/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts b/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts index b9e8004..581f652 100644 --- a/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts +++ b/src/main/ts/g0201_0300/s0234_palindrome_linked_list/solution.ts @@ -2,7 +2,7 @@ // #Level_2_Day_3_Linked_List #Udemy_Linked_List #Big_O_Time_O(n)_Space_O(1) // #2025_03_28_Time_3_ms_(92.85%)_Space_79.85_MB_(44.75%) -/* +/** * Definition for singly-linked list. * class ListNode { * val: number diff --git a/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts b/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts index 3fe559a..3acdf46 100644 --- a/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts +++ b/src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts @@ -3,7 +3,7 @@ // #Top_Interview_150_Binary_Tree_General #Big_O_Time_O(n)_Space_O(n) // #2025_03_28_Time_61_ms_(75.97%)_Space_65.98_MB_(36.62%) -/* +/** * Definition for a binary tree node. * class TreeNode { * val: number diff --git a/src/main/ts/g0201_0300/s0289_game_of_life/solution.ts b/src/main/ts/g0201_0300/s0289_game_of_life/solution.ts index 87a148f..4be31b3 100644 --- a/src/main/ts/g0201_0300/s0289_game_of_life/solution.ts +++ b/src/main/ts/g0201_0300/s0289_game_of_life/solution.ts @@ -7,7 +7,6 @@ function gameOfLife(board: number[][]): void { const m = board.length const n = board[0].length - for (let i = 0; i < m; i++) { for (let j = 0; j < n; j++) { const liveNeighbors = countLives(board, i, j, m, n) @@ -18,7 +17,6 @@ function gameOfLife(board: number[][]): void { } } } - for (let i = 0; i < m; i++) { for (let j = 0; j < n; j++) { board[i][j] >>= 1 diff --git a/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts b/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts index 3bcaa8e..9dc0d5e 100644 --- a/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts +++ b/src/main/ts/g0601_0700/s0637_average_of_levels_in_binary_tree/solution.ts @@ -16,7 +16,6 @@ import { TreeNode } from '../../com_github_leetcode/treenode' * } * } */ - function averageOfLevels(root: TreeNode | null): number[] { if (!root) { return [] From 0034ebe50c6eb51f785da6608a1b14a39392a850 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sun, 20 Apr 2025 14:34:18 +0300 Subject: [PATCH 49/49] Improved task 45 --- src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts b/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts index 800e710..ba92f55 100644 --- a/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts +++ b/src/main/ts/g0001_0100/s0045_jump_game_ii/solution.ts @@ -13,8 +13,9 @@ function jump(nums: number[]): number { if (i === currentEnd) { minJump++ currentEnd = farthest - - if (currentEnd >= nums.length - 1) break + if (currentEnd >= nums.length - 1) { + break + } } } return minJump