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 {
1010 int start = 0 ;
1111
1212 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);
1415 if (lastIndices[cur] < start) {
1516 lastIndices[cur] = i;
1617 curLen++ ;
Original file line number Diff line number Diff line change @@ -15,8 +15,10 @@ class Solution {
1515 int low = 0 ;
1616 int high = n1;
1717
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 ;
2022
2123 while (low <= high) {
2224 int cut1 = (low + high) ~ / 2 ;
Original file line number Diff line number Diff line change @@ -31,16 +31,14 @@ class Solution {
3131 // read digits
3232 while (current < s.length && digits.containsKey (s[current])) {
3333 int digit = digits[s[current++ ]]! ;
34- // check owerflow
34+ // check overflow
3535 if (sign == - 1 && res < (MIN + digit) / 10 ) {
3636 return MIN ;
3737 } else if (res > (MAX - digit) / 10 ) {
3838 return MAX ;
3939 }
40-
4140 res = res * 10 + sign * digit;
4241 }
43-
4442 return res;
4543 }
4644}
Original file line number Diff line number Diff line change 22// #Algorithm_II_Day_4_Two_Pointers #Big_O_Time_O(n)_Space_O(1)
33// #2024_09_30_Time_337_ms_(96.77%)_Space_172.5_MB_(64.52%)
44
5+ import 'dart:math' ;
6+
57class Solution {
68 int maxArea (List <int > height) {
79 int maxArea = - 1 ;
@@ -20,8 +22,4 @@ class Solution {
2022
2123 return maxArea;
2224 }
23-
24- int max (int a, int b) {
25- return (a > b) ? a : b;
26- }
2725}
Original file line number Diff line number Diff line change 22// #Algorithm_II_Day_13_Dynamic_Programming #Dynamic_Programming_I_Day_4
33// #Big_O_Time_O(n)_Space_O(1) #2024_10_04_Time_335_ms_(81.58%)_Space_148.6_MB_(76.32%)
44
5+ import 'dart:math' ;
6+
57class Solution {
68 int jump (List <int > nums) {
79 int length = 0 ;
@@ -25,9 +27,4 @@ class Solution {
2527
2628 return minJump;
2729 }
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- }
3330}
Original file line number Diff line number Diff line change 22// #Data_Structure_I_Day_3_Array #Dynamic_Programming_I_Day_7 #Level_1_Day_5_Greedy #Udemy_Arrays
33// #Big_O_Time_O(N)_Space_O(1) #2024_10_07_Time_374_ms_(89.33%)_Space_190.1_MB_(48.33%)
44
5+ import 'dart:math' ;
6+
57class Solution {
68 int maxProfit (List <int > prices) {
79 int maxProfit = 0 ;
@@ -17,6 +19,4 @@ class Solution {
1719
1820 return maxProfit;
1921 }
20-
21- int max (int a, int b) => a > b ? a : b; // Utility function for max
2222}
Original file line number Diff line number Diff line change 1212 * }
1313 */
1414class Solution {
15- int _max = - 999999999 ; // Use a large negative value instead of -double.infinity.toInt()
15+ int _max = - 999999999 ;
1616
1717 int _helper (TreeNode ? root) {
1818 if (root == null ) {
You can’t perform that action at this time.
0 commit comments