Skip to content

Updated tags for tasks 12-63 #1929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ implementation 'com.github.javadev:leetcode-in-java:1.41'
| 0392 |[Is Subsequence](src/main/java/g0301_0400/s0392_is_subsequence/Solution.java)| Easy | String, Dynamic_Programming, Two_Pointers | 1 | 93.01
| 0125 |[Valid Palindrome](src/main/java/g0101_0200/s0125_valid_palindrome/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers | 3 | 98.64
| 0977 |[Squares of a Sorted Array](src/main/java/g0901_1000/s0977_squares_of_a_sorted_array/Solution.java)| Easy | Array, Sorting, Two_Pointers | 1 | 100.00
| 0026 |[Remove Duplicates from Sorted Array](src/main/java/g0001_0100/s0026_remove_duplicates_from_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Two_Pointers | 1 | 98.56
| 0026 |[Remove Duplicates from Sorted Array](src/main/java/g0001_0100/s0026_remove_duplicates_from_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00
| 0042 |[Trapping Rain Water](src/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java)| 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/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 29 | 72.02

Expand Down Expand Up @@ -1488,7 +1488,7 @@ implementation 'com.github.javadev:leetcode-in-java:1.41'
|-|-|-|-|-|-
| 0088 |[Merge Sorted Array](src/main/java/g0001_0100/s0088_merge_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers | 0 | 100.00
| 0027 |[Remove Element](src/main/java/g0001_0100/s0027_remove_element/Solution.java)| Easy | Array, Two_Pointers | 0 | 100.00
| 0026 |[Remove Duplicates from Sorted Array](src/main/java/g0001_0100/s0026_remove_duplicates_from_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Two_Pointers | 1 | 98.56
| 0026 |[Remove Duplicates from Sorted Array](src/main/java/g0001_0100/s0026_remove_duplicates_from_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00
| 0080 |[Remove Duplicates from Sorted Array II](src/main/java/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/Solution.java)| Medium | Array, Two_Pointers | 0 | 100.00
| 0169 |[Majority Element](src/main/java/g0101_0200/s0169_majority_element/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.89
| 0189 |[Rotate Array](src/main/java/g0101_0200/s0189_rotate_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00
Expand Down Expand Up @@ -1525,10 +1525,10 @@ implementation 'com.github.javadev:leetcode-in-java:1.41'

| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
|-|-|-|-|-|-
| 0209 |[Minimum Size Subarray Sum](src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/Solution.java)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 1 | 100.00
| 0003 |[Longest Substring Without Repeating Characters](src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| 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 | 2 | 98.59
| 0030 |[Substring with Concatenation of All Words](src/main/java/g0001_0100/s0030_substring_with_concatenation_of_all_words/Solution.java)| Hard | String, Hash_Table, Sliding_Window | 1472 | 34.43
| 0030 |[Substring with Concatenation of All Words](src/main/java/g0001_0100/s0030_substring_with_concatenation_of_all_words/Solution.java)| Hard | String, Hash_Table, Sliding_Window | 11 | 97.43
| 0076 |[Minimum Window Substring](src/main/java/g0001_0100/s0076_minimum_window_substring/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 2 | 99.83
| 0209 |[Minimum Size Subarray Sum](src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/Solution.java)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 1 | 100.00

#### Top Interview 150 Matrix

Expand Down Expand Up @@ -1660,7 +1660,7 @@ implementation 'com.github.javadev:leetcode-in-java:1.41'
| 0077 |[Combinations](src/main/java/g0001_0100/s0077_combinations/Solution.java)| Medium | Backtracking | 11 | 77.40
| 0046 |[Permutations](src/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 94.08
| 0039 |[Combination Sum](src/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 99.99
| 0052 |[N-Queens II](src/main/java/g0001_0100/s0052_n_queens_ii/Solution.java)| Hard | Backtracking | 1 | 96.99
| 0052 |[N-Queens II](src/main/java/g0001_0100/s0052_n_queens_ii/Solution.java)| Hard | Backtracking | 0 | 100.00
| 0022 |[Generate Parentheses](src/main/java/g0001_0100/s0022_generate_parentheses/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 0 | 100.00
| 0079 |[Word Search](src/main/java/g0001_0100/s0079_word_search/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 64 | 98.51

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0012_integer_to_roman;

// #Medium #String #Hash_Table #Math #Top_Interview_150_Array/String
// #2024_02_11_Time_2_ms_(100.00%)_Space_44.1_MB_(80.61%)
// #2025_03_04_Time_2_(100.00%)_Space_44.30_(83.82%)

public class Solution {
public String intToRoman(int num) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0013_roman_to_integer;

// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Math
// #Top_Interview_150_Array/String #2024_02_11_Time_2_ms_(100.00%)_Space_44.5_MB_(76.62%)
// #Top_Interview_150_Array/String #2025_03_04_Time_2_(100.00%)_Space_44.54_(91.65%)

public class Solution {
public int romanToInt(String s) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package g0001_0100.s0014_longest_common_prefix;

// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #String #Level_2_Day_2_String
// #Udemy_Strings #Top_Interview_150_Array/String
// #2024_02_11_Time_0_ms_(100.00%)_Space_42_MB_(19.08%)
// #Udemy_Strings #Top_Interview_150_Array/String #2025_03_04_Time_0_(100.00%)_Space_41.35_(87.42%)

public class Solution {
public String longestCommonPrefix(String[] strs) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0026_remove_duplicates_from_sorted_array;

// #Easy #Top_Interview_Questions #Array #Two_Pointers #Udemy_Two_Pointers
// #Top_Interview_150_Array/String #2023_08_09_Time_1_ms_(98.56%)_Space_43.9_MB_(51.95%)
// #Top_Interview_150_Array/String #2025_03_04_Time_0_(100.00%)_Space_44.59_(95.49%)

public class Solution {
public int removeDuplicates(int[] nums) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0027_remove_element;

// #Easy #Array #Two_Pointers #Top_Interview_150_Array/String
// #2023_08_09_Time_0_ms_(100.00%)_Space_40.9_MB_(87.68%)
// #2025_03_04_Time_0_(100.00%)_Space_42.15_(29.50%)

public class Solution {
public int removeElement(int[] nums, int val) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// #Easy #Top_Interview_Questions #String #Two_Pointers #String_Matching
// #Programming_Skills_II_Day_1 #Top_Interview_150_Array/String
// #2023_08_09_Time_0_ms_(100.00%)_Space_40.5_MB_(71.14%)
// #2025_03_04_Time_0_(100.00%)_Space_41.19_(97.77%)

public class Solution {
public int strStr(String haystack, String needle) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
package g0001_0100.s0030_substring_with_concatenation_of_all_words;

// #Hard #String #Hash_Table #Sliding_Window #Top_Interview_150_Sliding_Window
// #2023_08_09_Time_1472_ms_(34.43%)_Space_45_MB_(24.98%)
// #2025_03_04_Time_11_(97.43%)_Space_45.96_(24.38%)

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SuppressWarnings("java:S127")
public class Solution {
public List<Integer> findSubstring(String s, String[] words) {
List<Integer> indices = new ArrayList<>();
if (words.length == 0) {
return indices;
List<Integer> ans = new ArrayList<>();
int n1 = words[0].length();
int n2 = s.length();
Map<String, Integer> map1 = new HashMap<>();
for (String ch : words) {
map1.put(ch, map1.getOrDefault(ch, 0) + 1);
}
// Put each word into a HashMap and calculate word frequency
Map<String, Integer> wordMap = new HashMap<>();
for (String word : words) {
wordMap.put(word, wordMap.getOrDefault(word, 0) + 1);
}
int wordLength = words[0].length();
int window = words.length * wordLength;
for (int i = 0; i < wordLength; i++) {
// move a word's length each time
for (int j = i; j + window <= s.length(); j = j + wordLength) {
// get the subStr
String subStr = s.substring(j, j + window);
Map<String, Integer> map = new HashMap<>();
// start from the last word
for (int k = words.length - 1; k >= 0; k--) {
// get the word from subStr
String word = subStr.substring(k * wordLength, (k + 1) * wordLength);
int count = map.getOrDefault(word, 0) + 1;
// if the num of the word is greater than wordMap's, move (k * wordLength) and
// break
if (count > wordMap.getOrDefault(word, 0)) {
j = j + k * wordLength;
break;
} else if (k == 0) {
indices.add(j);
} else {
map.put(word, count);
for (int i = 0; i < n1; i++) {
int left = i;
int j = i;
int c = 0;
Map<String, Integer> map2 = new HashMap<>();
while (j + n1 <= n2) {
String word1 = s.substring(j, j + n1);
j += n1;
if (map1.containsKey(word1)) {
map2.put(word1, map2.getOrDefault(word1, 0) + 1);
c++;
while (map2.get(word1) > map1.get(word1)) {
String word2 = s.substring(left, left + n1);
map2.put(word2, map2.get(word2) - 1);
left += n1;
c--;
}
if (c == words.length) {
ans.add(left);
}
} else {
map2.clear();
c = 0;
left = j;
}
}
}
return indices;

return ans;
}
}
2 changes: 1 addition & 1 deletion src/main/java/g0001_0100/s0036_valid_sudoku/Solution.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0036_valid_sudoku;

// #Medium #Top_Interview_Questions #Array #Hash_Table #Matrix #Data_Structure_I_Day_5_Array
// #Top_Interview_150_Matrix #2023_08_09_Time_1_ms_(100.00%)_Space_43.8_MB_(30.47%)
// #Top_Interview_150_Matrix #2025_03_04_Time_1_(100.00%)_Space_44.50_(57.83%)

public class Solution {
private int j1;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/g0001_0100/s0050_powx_n/Solution.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0050_powx_n;

// #Medium #Top_Interview_Questions #Math #Recursion #Udemy_Integers #Top_Interview_150_Math
// #2023_08_11_Time_0_ms_(100.00%)_Space_41.2_MB_(14.99%)
// #2025_03_04_Time_0_(100.00%)_Space_41.72_(93.18%)

public class Solution {
public double myPow(double x, int n) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/g0001_0100/s0052_n_queens_ii/Solution.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0052_n_queens_ii;

// #Hard #Backtracking #Top_Interview_150_Backtracking
// #2023_08_11_Time_1_ms_(96.99%)_Space_39.8_MB_(38.70%)
// #2025_03_04_Time_0_(100.00%)_Space_41.18_(24.45%)

public class Solution {
public int totalNQueens(int n) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/g0001_0100/s0054_spiral_matrix/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// #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 #2023_08_11_Time_0_ms_(100.00%)_Space_41_MB_(9.67%)
// #Top_Interview_150_Matrix #2025_03_04_Time_0_(100.00%)_Space_41.08_(99.19%)

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0057_insert_interval;

// #Medium #Array #Level_2_Day_17_Interval #Top_Interview_150_Intervals
// #2023_08_11_Time_0_ms_(100.00%)_Space_43.7_MB_(95.60%)
// #2025_03_04_Time_0_(100.00%)_Space_44.76_(89.09%)

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0058_length_of_last_word;

// #Easy #String #Programming_Skills_II_Day_6 #Udemy_Arrays #Top_Interview_150_Array/String
// #2023_08_11_Time_0_ms_(100.00%)_Space_40.3_MB_(97.60%)
// #2025_03_04_Time_0_(100.00%)_Space_41.72_(64.92%)

public class Solution {
public int lengthOfLastWord(String s) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/g0001_0100/s0061_rotate_list/Solution.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0061_rotate_list;

// #Medium #Two_Pointers #Linked_List #Programming_Skills_II_Day_16 #Udemy_Linked_List
// #Top_Interview_150_Linked_List #2023_08_11_Time_0_ms_(100.00%)_Space_41.1_MB_(94.89%)
// #Top_Interview_150_Linked_List #2025_03_04_Time_0_(100.00%)_Space_42.42_(78.37%)

import com_github_leetcode.ListNode;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0001_0100.s0063_unique_paths_ii;

// #Medium #Array #Dynamic_Programming #Matrix #Dynamic_Programming_I_Day_15
// #Top_Interview_150_Multidimensional_DP #2023_08_11_Time_0_ms_(100.00%)_Space_40.6_MB_(73.18%)
// #Top_Interview_150_Multidimensional_DP #2025_03_04_Time_0_(100.00%)_Space_41.62_(79.66%)

public class Solution {
public int uniquePathsWithObstacles(int[][] obstacleGrid) {
Expand Down