1
Answer

How to write an array of length 5, and calculating span

Ask a question
Sea Sun

Sea Sun

9y
592
1


Can somebody check my work???



SO I am given 5 prices: 100, 80, 60, 70, 100

my array fro price[] looks like:

var a = price[];
 a.length = 5;
 
 
 price[0] = 100;
 price[1] = 80;
 price[2] = 60;
 price[3] = 70;
 price[4] = 100;


and for array to hold calculated spans, S[] is:


 
 var a = S[];
 a.length = 5;
 
 S[0] = 1;
 S[1] = 1;
 S[2] = 1;
 S[3] = 2;
 S[4] = 5;
 



Answers (1)