Advertisement
DPOH-VAR

Untitled

May 22nd, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const store = [];
  2. let maxPrev10 = -Infinity;
  3. let result = -Infinity;
  4.  
  5. [1,1,1,1,1,5,1,1,1,1,1,1,1,1,5,1,1,1,1,1,1,].forEach((v, i) => {
  6.   if (i < 10) {
  7.     store.push(v);
  8.     return;
  9.   }
  10.   maxPrev10 = Math.max(maxPrev10, store.shift());
  11.   store.push(v);
  12.   result = Math.max(result, maxPrev10 ** 2 + v ** 2 )
  13. });
  14.  
  15. console.log(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement