(프로그래머 – JAVA) 내적



  • 내 솔루션
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();
    }
}