[프로그래머스]최솟값 만들기(Python)

2022. 9. 16. 11:35·CodingTest/Programmers

0. 문제 링크

https://school.programmers.co.kr/learn/courses/30/lessons/12941

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

1. 문제 설명

1) 두 배열에서 중복되지 않게 선택해서 곱한 수의

2) 최소값 구하기

 

2. 입출력

# input
A = [1,4,2]
B = [5,4,4]

# output
result = 29

 

3. 코드

def solution(A,B):
    answer = 0

    A = sorted(A)                   # A 오름차순 정렬
    B = sorted(B, reverse=True)     # B 내림차순 정렬

    for i in range(len(A)):
        answer += A[i] * B[i]       # 순서대로 곱하기

    return answer

 

실행 결과

 

4. 알게된 점

1) 최소값을 찾기 위해서 각 배열의 정렬을 활용

 

5. Github

https://github.com/iihye/Algorithm/blob/main/Programmers/make_min.py

 

GitHub - iihye/Algorithm

Contribute to iihye/Algorithm development by creating an account on GitHub.

github.com

 

728x90
저작자표시 비영리 변경금지 (새창열림)

'CodingTest > Programmers' 카테고리의 다른 글

[프로그래머스]숫자의 표현(Python)  (0) 2022.09.18
[프로그래머스]올바른 괄호(Python)  (0) 2022.09.17
[프로그래머스]JadenCase 문자열 만들기(Python)  (0) 2022.09.15
[프로그래머스]최댓값과 최솟값(Python)  (0) 2022.09.14
[프로그래머스]성격 유형 검사하기(Python)  (0) 2022.09.06
'CodingTest/Programmers' 카테고리의 다른 글
  • [프로그래머스]숫자의 표현(Python)
  • [프로그래머스]올바른 괄호(Python)
  • [프로그래머스]JadenCase 문자열 만들기(Python)
  • [프로그래머스]최댓값과 최솟값(Python)
iihye_
iihye_
  • iihye_
    hye-log
    iihye_
    • 분류 전체보기 (296)
      • Development (19)
        • Spring (4)
        • Python (5)
        • React (4)
        • Next.js (1)
        • JavaScript (4)
        • CSS (1)
      • Infra (15)
        • Docker (1)
        • Jenkins (2)
        • Nginx (3)
        • JBoss (1)
        • Windows (3)
        • Linux (3)
        • Kafka (2)
      • Database (1)
        • MongoDB (1)
      • Tools (2)
        • Git (0)
        • Github (1)
        • Document (1)
      • CodingTest (125)
        • Programmers (38)
        • Baekjoon (52)
        • SWEA (27)
        • Jungol (4)
        • Codetree (1)
        • Goorm (3)
      • Education (99)
        • SSAFY 10기 (5)
        • AI Tech 4기 (94)
      • NomadCoder (35)
        • (JS)크롬 앱 만들기 (35)
      • Notice (0)
  • 링크

    • Github
  • 인기 글

  • 최근 글

  • 전체
    오늘
    어제
  • hELLO· Designed By정상우.v4.10.5
iihye_
[프로그래머스]최솟값 만들기(Python)
상단으로

티스토리툴바