기본 콘텐츠로 건너뛰기

프로그래머스 - 최솟값 만들기

import java.util.Arrays;

public class TryHelloWorld
{

    public int getMinSum(int []A, int []B)
    {
        int answer = 0;
        Arrays.sort(A);
        Arrays.sort(B);

        for(int i=0;i<B.length;i++) {
            answer += A[i]*B[B.length-1-i];
        }

        return answer;
    }
    public static void main(String[] args)
    {
        TryHelloWorld test = new TryHelloWorld();
        int []A = {1,2};
        int []B = {3,4};
        System.out.println(test.getMinSum(A,B));
    }
}

댓글

이 블로그의 인기 게시물