File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 99 " https://en.wikipedia.org/wiki/Dynamic_programming"
1010 ],
1111 "files" : {
12- "fibonacci" : " Fibonacci Sequence"
12+ "fibonacci" : " Fibonacci Sequence" ,
13+ "sliding_window" : " Finding the largest sum of three contiguous number"
1314 }
1415}
Original file line number Diff line number Diff line change 1+ tracer . _pace ( 500 ) ;
2+ var sum = D [ 0 ] + D [ 1 ] + D [ 2 ] ;
3+ var max = sum ;
4+ tracer . _print ( 'sum = ' + sum , false ) ;
5+ tracer . _selectSet ( [ 0 , 1 , 2 ] ) ;
6+ for ( var i = 3 ; i < D . length ; i ++ ) {
7+ sum += D [ i ] - D [ i - 3 ] ;
8+ if ( max < sum ) max = sum ;
9+ tracer . _print ( 'sum = ' + sum , false ) ;
10+ tracer . _deselect ( i - 3 ) ;
11+ tracer . _select ( i ) ;
12+ }
13+ tracer . _deselectSet ( [ D . length - 3 , D . length - 2 , D . length - 1 ] ) ;
14+ tracer . _print ( 'max = ' + max ) ;
Original file line number Diff line number Diff line change 1+ var tracer = new Array1DTracer ( ) ;
2+ var D = tracer . createRandomData ( 20 , - 5 , 5 ) ;
3+ tracer . setData ( D ) ;
You can’t perform that action at this time.
0 commit comments