« first day (2628 days earlier)      last day (1474 days later) » 

 
2 hours later…
4:41 AM
60950878; 60950942; 60951035; 60951145; 60951154; 60951649; 60952385; 60952811; 60952904; 60953907; 60953981; 60954082; 60954256; 60954521; 60955322; 60955404; 60955772; 60955792; 60955844; 60955897; 60957309; 60957543; 60957661; 60958119; 60958378; 60958421; 60958568; 60958641; 60958703; 60958747; 60958777; 60958800; 60958989; 60959047; 60959144; 60959231; 60959649; 60959726; 60959751; 60959870; 60960187; 60960501; 60962122; 60962249; 60962297; 60962433; 60962448; 60962466; 60962555; 60963466;
60963736; 60964334; 60964530; 60964634; 60964664; 60967648; 60969713; 60969952; 60970259; 60970497; 60970543; 60970559; 60970631; 60970674; 60971479; 60971906; 60971916; 60971963; 60972182; 60972727; 60973207; 60973397; 60973985; 60974031; 60974164; 60974568; 60975577; 60976075; 60976429; 60976574; 60976705; 60976826; 60979808; 60979929; 60980638; 60980685; 60980950; 60980980; 60981009; 60981311; 60981361; 60981587; 60982094; 60982221; 60982301; 60982362; 60982481; 60982884; 60989811; 60990278;
60991287; 60991501; 60991789; 60991817; 60992074; 60993173; 60993183; 60994093; 60994185; 60994871; 60996399; 60996836; 60997752; 60998318; 60998435; 60998469; 60998544; 60998809; 60998928; 60999042; 60999285; 60999918; 60999995; 61000053; 61000172; 61000215; 61000631; 61000660; 61000668; 61001656; 61002120; 61002153; 61002490; 61002511; 61002524; 61002573; 61002876; 61002993; 61003022; 61003050; 61003126; 61003261; 61003262; 61003669; 61004221; 61004553; 61004838; 61004843; 61005037; 61005739;
61006549; 61006818; 61006867; 61006927; 61006939; 61006991; 61007067; 61007070; 61007209; 61007253; 61007356; 61007383; 61007405; 61007442; 61007951; 61007994; 61008048; 61008300; 61008583; 61008593; 61008664; 61011359; 61011465; 61011530; 61011995; 61012109; 61013386; 61013390; 61013612; 61013722; 61013783; 61014056; 61014166; 61015006; 61016375; 61016585; 61016670; 61016788; 61016935; 61017086; 61017177; 61017374; 61017838; 61017862; 61018008; 61018011; 61018095; 61018305; 61018323; 61018335;
61018399; 61018665; 61018668; 61018682; 61018785; 61018801; 61018818; 61018824; 61019183; 61019553; 61019718; 61019955; 61020451; 61020595; 61021263; 61021282; 61021364; 61021379; 61021957; 61022038; 61022118; 61022218; 61022447; 61023619; 61023923; 61023956; 61024073; 61024152; 61024197; 61024421; 61024539; 61024625; 61024627; 61024661; 61024787; 61024840; 61024987; 61025026; 61025047; 61025127; 61025151; 61025210; 61025350; 61025388; 61025547; 61026004; 61027904; 61028390; 61028401; 61028617;
61028719; 61028955; 61029729; 61029835; 61029959; 61030264; 61030345; 61030706; 61030718; 61030812; 61030844; 61030853; 61031624; 61031981; 61032175; 61032282; 61033352; 61033397; 61033519; 61033545; 61033673; 61034600; 61034633; 61034682; 61034794; 61035011; 61035420; 61035494; 61035686; 61035713; 61035755; 61035795; 61036031; 61036282; 61036766; 61036892; 61036926; 61036968; 61036975; 61036987; 61037213; 61037219; 61037221; 61037264; 61037298; 61037366; 61037424
 
6 messages moved from SOBotics
 
 
14 hours later…
6:16 PM
the most important thing here i think is max(0, current_sum + x)
We know the following:
Y + Z > Z; if z and y are positive
In this case, Y is x and Z is any positive future sum.
"any positive future sum" is any future subarray that's sum is postiive
We also know:
Y + Z < Z; if Z is positive and Y is negative
So we know that if the previous sum (all numbers up to this point) is negative any future sub array must be greater than the current sum or equal (if its zero)
I know that is very confusing.
So lets break it down:
10 messages moved from JavaScript
 
6:35 PM
function max_subarray(numbers){
best_sum = 0;
current_sum = 0;
for(let x of numbers){
current_sum = Math.max(0, current_sum + x);
best_sum = Math.max(best_sum, current_sum);
}
return best_sum;
}
 
1 message moved from JavaScript
 

« first day (2628 days earlier)      last day (1474 days later) »