File tree Expand file tree Collapse file tree 7 files changed +14
-18
lines changed
s0003_longest_substring_without_repeating_characters
s0004_median_of_two_sorted_arrays
s0008_string_to_integer_atoi
s0011_container_with_most_water
s0121_best_time_to_buy_and_sell_stock
s0124_binary_tree_maximum_path_sum Expand file tree Collapse file tree 7 files changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ class Solution {
10
10
int start = 0 ;
11
11
12
12
for (int i = 0 ; i < s.length; i++ ) {
13
- int cur = s.codeUnitAt (i); // Getting ASCII value of the character
13
+ // Getting ASCII value of the character
14
+ int cur = s.codeUnitAt (i);
14
15
if (lastIndices[cur] < start) {
15
16
lastIndices[cur] = i;
16
17
curLen++ ;
Original file line number Diff line number Diff line change @@ -15,8 +15,10 @@ class Solution {
15
15
int low = 0 ;
16
16
int high = n1;
17
17
18
- int minValue = - pow (2 , 31 ).toInt (); // substitute for Integer.MIN_VALUE
19
- int maxValue = pow (2 , 31 ).toInt () - 1 ; // substitute for Integer.MAX_VALUE
18
+ // substitute for Integer.MIN_VALUE
19
+ int minValue = - pow (2 , 31 ).toInt ();
20
+ // substitute for Integer.MAX_VALUE
21
+ int maxValue = pow (2 , 31 ).toInt () - 1 ;
20
22
21
23
while (low <= high) {
22
24
int cut1 = (low + high) ~ / 2 ;
Original file line number Diff line number Diff line change @@ -31,16 +31,14 @@ class Solution {
31
31
// read digits
32
32
while (current < s.length && digits.containsKey (s[current])) {
33
33
int digit = digits[s[current++ ]]! ;
34
- // check owerflow
34
+ // check overflow
35
35
if (sign == - 1 && res < (MIN + digit) / 10 ) {
36
36
return MIN ;
37
37
} else if (res > (MAX - digit) / 10 ) {
38
38
return MAX ;
39
39
}
40
-
41
40
res = res * 10 + sign * digit;
42
41
}
43
-
44
42
return res;
45
43
}
46
44
}
Original file line number Diff line number Diff line change 2
2
// #Algorithm_II_Day_4_Two_Pointers #Big_O_Time_O(n)_Space_O(1)
3
3
// #2024_09_30_Time_337_ms_(96.77%)_Space_172.5_MB_(64.52%)
4
4
5
+ import 'dart:math' ;
6
+
5
7
class Solution {
6
8
int maxArea (List <int > height) {
7
9
int maxArea = - 1 ;
@@ -20,8 +22,4 @@ class Solution {
20
22
21
23
return maxArea;
22
24
}
23
-
24
- int max (int a, int b) {
25
- return (a > b) ? a : b;
26
- }
27
25
}
Original file line number Diff line number Diff line change 2
2
// #Algorithm_II_Day_13_Dynamic_Programming #Dynamic_Programming_I_Day_4
3
3
// #Big_O_Time_O(n)_Space_O(1) #2024_10_04_Time_335_ms_(81.58%)_Space_148.6_MB_(76.32%)
4
4
5
+ import 'dart:math' ;
6
+
5
7
class Solution {
6
8
int jump (List <int > nums) {
7
9
int length = 0 ;
@@ -25,9 +27,4 @@ class Solution {
25
27
26
28
return minJump;
27
29
}
28
-
29
- // Dart's equivalent for Java's Math.max() is the built-in max() function
30
- int max (int a, int b) {
31
- return a > b ? a : b;
32
- }
33
30
}
Original file line number Diff line number Diff line change 2
2
// #Data_Structure_I_Day_3_Array #Dynamic_Programming_I_Day_7 #Level_1_Day_5_Greedy #Udemy_Arrays
3
3
// #Big_O_Time_O(N)_Space_O(1) #2024_10_07_Time_374_ms_(89.33%)_Space_190.1_MB_(48.33%)
4
4
5
+ import 'dart:math' ;
6
+
5
7
class Solution {
6
8
int maxProfit (List <int > prices) {
7
9
int maxProfit = 0 ;
@@ -17,6 +19,4 @@ class Solution {
17
19
18
20
return maxProfit;
19
21
}
20
-
21
- int max (int a, int b) => a > b ? a : b; // Utility function for max
22
22
}
Original file line number Diff line number Diff line change 12
12
* }
13
13
*/
14
14
class Solution {
15
- int _max = - 999999999 ; // Use a large negative value instead of -double.infinity.toInt()
15
+ int _max = - 999999999 ;
16
16
17
17
int _helper (TreeNode ? root) {
18
18
if (root == null ) {
You can’t perform that action at this time.
0 commit comments