Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/g0101_0200/s0112_path_sum/Solution.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0101_0200.s0112_path_sum;

// #Easy #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree #Data_Structure_I_Day_12_Tree
// #Top_Interview_150_Binary_Tree_General #2022_06_23_Time_0_ms_(100.00%)_Space_43.8_MB_(36.11%)
// #Top_Interview_150_Binary_Tree_General #2025_03_06_Time_0_ms_(100.00%)_Space_43.07_MB_(76.46%)

import com_github_leetcode.TreeNode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// #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 #2022_06_23_Time_0_ms_(100.00%)_Space_44.7_MB_(65.49%)
// #Top_Interview_150_Binary_Tree_General #2025_03_06_Time_0_ms_(100.00%)_Space_44.12_MB_(80.39%)

import com_github_leetcode.left_right.Node;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/g0101_0200/s0120_triangle/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// #Medium #Array #Dynamic_Programming #Algorithm_I_Day_12_Dynamic_Programming
// #Dynamic_Programming_I_Day_13 #Udemy_Dynamic_Programming #Top_Interview_150_Multidimensional_DP
// #2022_06_23_Time_2_ms_(94.63%)_Space_44.2_MB_(36.02%)
// #2025_03_06_Time_1_ms_(99.79%)_Space_44.45_MB_(35.64%)

import java.util.Arrays;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// #Medium #Top_Interview_Questions #Array #Dynamic_Programming #Greedy #Dynamic_Programming_I_Day_7
// #Udemy_Arrays #Top_Interview_150_Array/String
// #2022_06_23_Time_1_ms_(96.82%)_Space_44.7_MB_(25.11%)
// #2025_03_06_Time_1_ms_(76.91%)_Space_45.72_MB_(69.34%)

public class Solution {
public int maxProfit(int[] prices) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0101_0200.s0123_best_time_to_buy_and_sell_stock_iii;

// #Hard #Array #Dynamic_Programming #Top_Interview_150_Multidimensional_DP
// #2022_06_23_Time_4_ms_(87.18%)_Space_78.4_MB_(61.70%)
// #2025_03_06_Time_4_ms_(74.67%)_Space_61.08_MB_(72.04%)

public class Solution {
public int maxProfit(int[] prices) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0101_0200.s0125_valid_palindrome;

// #Easy #Top_Interview_Questions #String #Two_Pointers #Udemy_Two_Pointers
// #Top_Interview_150_Two_Pointers #2022_06_23_Time_3_ms_(98.64%)_Space_43.2_MB_(81.23%)
// #Top_Interview_150_Two_Pointers #2025_03_06_Time_2_ms_(99.11%)_Space_43.15_MB_(70.82%)

public class Solution {
public boolean isPalindrome(String s) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/g0101_0200/s0127_word_ladder/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// #Hard #Top_Interview_Questions #String #Hash_Table #Breadth_First_Search
// #Graph_Theory_I_Day_12_Breadth_First_Search #Top_Interview_150_Graph_BFS
// #2022_06_23_Time_37_ms_(94.58%)_Space_54.1_MB_(66.08%)
// #2025_03_06_Time_22_ms_(96.00%)_Space_45.97_MB_(83.68%)

import java.util.HashSet;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0101_0200.s0129_sum_root_to_leaf_numbers;

// #Medium #Depth_First_Search #Tree #Binary_Tree #Top_Interview_150_Binary_Tree_General
// #2022_06_23_Time_0_ms_(100.00%)_Space_41.8_MB_(46.81%)
// #2025_03_06_Time_0_ms_(100.00%)_Space_41.47_MB_(30.87%)

import com_github_leetcode.TreeNode;

Expand Down
30 changes: 11 additions & 19 deletions src/main/java/g0101_0200/s0134_gas_station/Solution.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
package g0101_0200.s0134_gas_station;

// #Medium #Top_Interview_Questions #Array #Greedy #Top_Interview_150_Array/String
// #2022_06_24_Time_2_ms_(94.26%)_Space_62.5_MB_(87.11%)
// #2025_03_06_Time_2_ms_(97.52%)_Space_57.00_MB_(5.82%)

public class Solution {
public int canCompleteCircuit(int[] gas, int[] cost) {
int sumGas = 0;
int sumCost = 0;
int curGas = 0;
int result = -1;
int index = 0;
int total = 0;
int current = 0;
for (int i = 0; i < gas.length; i++) {
curGas += gas[i] - cost[i];
// re-calculate the starting point
if (curGas < 0) {
result = -1;
curGas = 0;
} else if (result == -1) {
// set initial starting point
result = i;
int balance = gas[i] - cost[i];
total += balance;
current += balance;
if (current < 0) {
index = i + 1;
current = 0;
}
sumGas += gas[i];
sumCost += cost[i];
}
if (sumGas < sumCost) {
return -1;
}
return result;
return total >= 0 ? index : -1;
}
}
2 changes: 1 addition & 1 deletion src/main/java/g0101_0200/s0135_candy/Solution.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0101_0200.s0135_candy;

// #Hard #Array #Greedy #Top_Interview_150_Array/String
// #2022_06_24_Time_2_ms_(99.95%)_Space_42.8_MB_(94.28%)
// #2025_03_06_Time_3_ms_(83.95%)_Space_45.91_MB_(43.68%)

import java.util.Arrays;

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

// #Medium #Array #Bit_Manipulation #Top_Interview_150_Bit_Manipulation
// #2022_06_24_Time_0_ms_(100.00%)_Space_42.1_MB_(84.59%)
// #2025_03_06_Time_0_ms_(100.00%)_Space_45.39_MB_(79.09%)

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

// #Hard #Top_Interview_Questions #Array #Hash_Table #Math #Geometry #Algorithm_II_Day_21_Others
// #Top_Interview_150_Math #2022_06_24_Time_11_ms_(99.21%)_Space_41.5_MB_(95.53%)
// #Top_Interview_150_Math #2025_03_06_Time_7_ms_(99.18%)_Space_41.70_MB_(81.57%)

public class Solution {
public int maxPoints(int[][] points) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g0101_0200.s0150_evaluate_reverse_polish_notation;

// #Medium #Top_Interview_Questions #Array #Math #Stack #Programming_Skills_II_Day_3
// #Top_Interview_150_Stack #2022_06_24_Time_9_ms_(51.23%)_Space_44.1_MB_(56.86%)
// #Top_Interview_150_Stack #2025_03_06_Time_6_ms_(76.50%)_Space_44.94_MB_(31.04%)

import java.util.Stack;

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

// #Medium #String #Two_Pointers #Udemy_Strings #Top_Interview_150_Array/String
// #2022_06_25_Time_2_ms_(99.94%)_Space_42.4_MB_(88.57%)
// #2025_03_06_Time_2_ms_(99.69%)_Space_42.48_MB_(97.99%)

public class Solution {
public String reverseWords(String s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// #Medium #Top_Interview_Questions #Array #Binary_Search #Algorithm_II_Day_2_Binary_Search
// #Binary_Search_II_Day_12 #Top_Interview_150_Binary_Search
// #2022_06_25_Time_0_ms_(100.00%)_Space_43.5_MB_(12.83%)
// #2025_03_06_Time_0_ms_(100.00%)_Space_42.78_MB_(21.39%)

public class Solution {
public int findPeakElement(int[] nums) {
Expand Down