728x90

알고리즘/해결 43

[프로그래머스] 없는 숫자 더하기

1. 문제 0부터 9까지의 숫자 중 일부가 들어있는 배열 numbers가 매개변수로 주어집니다. numbers에서 찾을 수 없는 0부터 9까지의 숫자를 모두 찾아 더한 수를 return 하도록 solution 함수를 완성해주세요. 2. 나의 답 func solution(_ numbers:[Int]) -> Int { let sumValue = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 var inputValue = 0 numbers.forEach { value in inputValue += value } return sumValue - inputValue } 3. 다른 방법 func solution(_ numbers:[Int]) -> Int { let sumValue = 1 + 2 + 3..

알고리즘/해결 2021.12.08

LeetCode1450. Number of Students Doing Homework at a Given Time

1. 문제(원본) Given two integer arrays startTime and endTime and given an integer queryTime. The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i]. Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive. Example 1: In..

알고리즘/해결 2020.05.18
728x90