프로그래머스/[프로그래머스 - JAVA] Lv.1
[프로그래머스 - JAVA] 내적
코딩하는 흰둥이
2023. 3. 28. 20:20
- 내 풀이
class Solution {
public int solution(int[] a, int[] b) {
int answer = 1234567890;
answer = 0;
for (int i = 0; i < a.length; i++) {
answer += a[i] * b[i];
}
return answer;
}
}
- 다른 사람 풀이
class Solution {
public int solution(int[] a, int[] b) {
return IntStream.range(0, a.length).map(index -> a[index] * b[index]).sum();
}
}