subject

How can I reduce the number of loops, possibly into one loop on my solution below? The logic is right and it passes all my test cases but it looks a bit verbose. const hourglassSum = (arr) => { let count = 1; const hourglass = []; const flatglass = []; let idx = 0; do { const idx2 = idx + 1; const idx3 = idx + 2; hourglass. push([ [arr[0][idx], arr[0][idx2], arr[0][idx3]], [0, arr[1][idx2], 0], [arr[2][idx], arr[2][idx2], arr[2][idx3]], ]); idx += 1; count += 1; } while (count 4 && count 8 && count 12 && count { const flattened = [].concat(...innerglass); const arrSum = flattened. reduce((a, b) => a + b, 0); flatglass. push(arrSum); }); return Math. max(...flatglass); };

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 11:30
Auser is given read permission to a file stored on an ntfs-formatted volume. the file is then copied to a folder on the same ntfs-formatted volume where the user has been given full control permission for that folder. when the user logs on to the computer holding the file and accesses its new location via a drive letter, what is the user's effective permission to the file? a. read b. full control c. no access d. modify e. none of the above
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Plz ( which is an example of a good url?
Answers: 1
question
Computers and Technology, 24.06.2019 09:40
Healthy study habits are best described as
Answers: 1
question
Computers and Technology, 25.06.2019 01:30
What controls can be found on the file tab of microsoft word
Answers: 1
You know the right answer?
How can I reduce the number of loops, possibly into one loop on my solution below? The logic is righ...
Questions
question
Mathematics, 28.02.2021 22:00
question
Mathematics, 28.02.2021 22:00
question
English, 28.02.2021 22:00
Questions on the website: 13722363