목록전체 글 (102)
개발자도전
[문제] 머쓱이네 옷가게는 10만 원 이상 사면 5%, 30만 원 이상 사면 10%, 50만 원 이상 사면 20%를 할인해줍니다. 구매한 옷의 가격 price가 주어질 때, 지불해야 할 금액을 return 하도록 solution 함수를 완성해보세요. [입출력 예] price result 150,000 142,500 580,000 464,000 입출력 예 #1 150,000원에서 5%를 할인한 142,500원을 return 합니다. 입출력 예 #2 580,000원에서 20%를 할인한 464,000원을 return 합니다. [답] 답 1. 처음에 if문을 사용해서 10만원 이상일 경우 또 if문을 적용해서 할인값을 계산해주었다. 그렇지만 코드가 보기 불편하고 길어져서 다른 사람들의 코드를 참고해서 다시 작성..
[문제] Given an array arr of integers, check if there exist two indices i and j such that : i != j 0
[문제] 정수 배열 numbers가 매개변수로 주어집니다. numbers의 원소의 평균값을 return하도록 solution 함수를 완성해주세요. [입출력 예] numbers result [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 5.5 [89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99] 94.0 입출력 예 #1 numbers의 원소들의 평균 값은 5.5입니다. 입출력 예 #2 numbers의 원소들의 평균 값은 94.0입니다. [답] numbers의 길이를 선언해주고 for문을 돌려주었다. numbers의 i번째 값들을 answer에 더해주고 return값에서 answer을 numbers의 길이를 나눠주었다.
[문제] Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k element..
[문제] Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the first k ele..
[문제] 머쓱이네 피자가게는 피자를 두 조각에서 열 조각까지 원하는 조각 수로 잘라줍니다. 피자 조각 수 slice와 피자를 먹는 사람의 수 n이 매개변수로 주어질 때, n명의 사람이 최소 한 조각 이상 피자를 먹으려면 최소 몇 판의 피자를 시켜야 하는지를 return 하도록 solution 함수를 완성해보세요. [입출력 예] slice n result 7 10 2 4 12 3 입출력 예 #1 10명이 7조각으로 자른 피자를 한 조각 이상씩 먹으려면 최소 2판을 시켜야 합니다. 입출력 예 #2 12명이 4조각으로 자른 피자를 한 조각 이상씩 먹으려면 최소 3판을 시켜야 합니다. [답]