I am a fourth-year student at the Belarusian State University of Informatics and Radioelectronics, majoring in Information Systems and Technologies. I have a strong passion for Java application development and I am eager to pursue a career in this field while continuously expanding my knowledge of new technologies. As a motivated individual, I thrive on tackling complex problems and finding innovative solutions. I am excited about the opportunity to contribute as an intern or junior Java backend developer.
Peak array index KATA from CODEWARS: Given an array of ints, return the index such that the sum of the elements to the right of that index equals the sum of the elements to the left of that index. If there is no such index, return -1. If there is more than one such index, return the left-most index.
function peak(arr) {
for (let i = 1; i < arr.length - 1; i++) {
let leftSum = arr.slice(0, i).reduce((accumulator, currentValue) => accumulator + currentValue);
let rightSum = arr.slice(i + 1).reduce((accumulator, currentValue) => accumulator + currentValue);
if (leftSum === rightSum) {
return i;
}
}
return -1;
}
