[JAVA 문제 풀이] 236. 내적

프로그래머스 (70128)
Stupefyee's avatar
May 02, 2025
[JAVA 문제 풀이] 236. 내적
notion image
 

내가 작성한 코드

class Solution { public int solution(int[] a, int[] b) { int answer = 0; for(int i = 0; i < a.length; i++) { answer += a[i] * b[i]; } return answer; } }
 

다른 사람의 코드

import java.util.stream.IntStream; class Solution { public int solution(int[] a, int[] b) { return IntStream.range(0, a.length).map(index -> a[index] * b[index]).sum(); } }
 
Share article

stupefyee