감사합니다 :)
function solution(m, arr) {
let answer = 0;
let n = arr.length
let p1 = 0;
let p2 = p1 + 1;
let sum = arr[0];
if(n===1){
if(sum===m) {
answer++;
return answer;
}
}
while (p2 < n) {
sum += arr[p2];
if (sum === m || sum-arr[p2]===m) {
answer++;
p1++;
p2 = p1 + 1;
sum = arr[p1];
}
else {
if (sum < m) p2++;
else {
p1++;
p2 = p1 + 1;
sum = arr[p1];
}
}
}
return answer;
}