목록알고리즘 (98)
forest_moon
문제 설명 문자열 my_string이 매개변수로 주어집니다. my_string안의 모든 자연수들의 합을 return하도록 solution 함수를 완성해주세요. 제한사항 1 ≤ my_string의 길이 ≤ 1,000 my_string은 소문자, 대문자 그리고 한자리 자연수로만 구성되어있습니다. 입출력 예 my_string result "aAb1B2cC34oOp" 10 "1a2b3c4d123" 16 입출력 예 설명 입출력 예 #1 "aAb1B2cC34oOp"안의 한자리 자연수는 1, 2, 3, 4 입니다. 따라서 1 + 2 + 3 + 4 = 10 을 return합니다. 입출력 예 #2 "1a2b3c4d123Z"안의 한자리 자연수는 1, 2, 3, 4, 1, 2, 3 입니다. 따라서 1 + 2 + 3 + 4 ..
문제 설명 문자열 my_string이 매개변수로 주어질 때, my_string 안에 있는 숫자만 골라 오름차순 정렬한 리스트를 return 하도록 solution 함수를 작성해보세요. 제한사항 1 ≤ my_string의 길이 ≤ 100 my_string에는 숫자가 한 개 이상 포함되어 있습니다. my_string은 영어 소문자 또는 0부터 9까지의 숫자로 이루어져 있습니다. - - - 입출력 예 my_string result "hi12392" [1, 2, 2, 3, 9] "p2o4i8gj2" [2, 2, 4, 8] "abcde0" [0] 입출력 예 설명 입출력 예 #1 "hi12392"에 있는 숫자 1, 2, 3, 9, 2를 오름차순 정렬한 [1, 2, 2, 3, 9]를 return 합니다. 입출력 예 ..
문제 설명 영어에선 a, e, i, o, u 다섯 가지 알파벳을 모음으로 분류합니다. 문자열 my_string이 매개변수로 주어질 때 모음을 제거한 문자열을 return하도록 solution 함수를 완성해주세요. 제한사항 my_string은 소문자와 공백으로 이루어져 있습니다. 1 ≤ my_string의 길이 ≤ 1,000 입출력 예 my_string result "bus" "bs" "nice to meet you" "nc t mt y" 입출력 예 설명 입출력 예 #1 "bus"에서 모음 u를 제거한 "bs"를 return합니다. 입출력 예 #1 "nice to meet you"에서 모음 i, o, e, u를 모두 제거한 "nc t mt y"를 return합니다. class Solution { publi..
import java.util.*; class Solution { public int[] solution(String my_string) { my_string = my_string.replaceAll("[a-z]",""); int[] answer = new int[my_string.length()]; for(int i =0; i
문제 CAR_RENTAL_COMPANY_CAR 테이블에서 '네비게이션' 옵션이 포함된 자동차 리스트를 출력하는 SQL문을 작성해주세요. 결과는 자동차 ID를 기준으로 내림차순 정렬해주세요. 코드 SELECT * FROM CAR_RENTAL_COMPANY_CAR WHERE OPTIONS LIKE '%네비게이션%' ORDER BY CAR_ID DESC
코드 SELECT HISTORY_ID, CAR_ID, DATE_FORMAT(START_DATE,'%Y-%m-%d') AS START_DATE, DATE_FORMAT(END_DATE,'%Y-%m-%d') AS END_DATE, CASE WHEN DATEDIFF(END_DATE,START_DATE) >= 29 THEN '장기 대여' ELSE '단기 대여' END AS RENT_TYPE FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY WHERE DATE_FORMAT(START_DATE,'%Y-%m') = '2022-09' ORDER BY HISTORY_ID DESC *** DATE_FORAMT은 코테 하면서 풀어봐서 바로 변환 했는데 기간 확인하는 함수를 몰라서 찾아보니까 DATEDIFF..
코드 class Solution { public int[] solution(int[] numbers, String direction) { int[] answer = new int[numbers.length]; if (direction.equals("right")) { answer[0] = numbers[numbers.length -1]; for (int i = 0; i < numbers.length - 1; i++) { answer[i + 1] = numbers[i]; } } else { answer[answer.length - 1] = numbers[0]; for (int i = 1; i < numbers.length; i++) { answer[i - 1] = numbers[i]; } } return ..