시간복잡도
-
Codility - CountDivAlgorithm 2021. 9. 12. 14:30
아래 문제는 코딜리티에서 제공하는 CountDiv의 문제입니다🧑🏻💻 문제 제시 Write a function: public func solution(_ A : Int, _ B : Int, _ K : Int) -> Int that, given three integers A, B and K, returns the number of integers within the range [A..B] that are divisible by K, i.e.: { i : A ≤ i ≤ B, i mod K = 0 } For example, for A = 6, B = 11 and K = 2, your function should return 3, because there are three numbers divisible by ..
-
시간복잡도를 고려한 알고리즘 (3)Algorithm 2021. 7. 11. 13:50
아래 문제는 코딜리티에서 제공하는 TapeEquilibrium의 문제입니다🧑🏻💻 문제 제시 A non-empty array A consisting of N integers is given. Array A represents numbers on a tape. Any integer P, such that 0 < P < N, splits this tape into two non-empty parts: A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[N − 1]. The difference between the two parts is the value of: |(A[0] + A[1] + ... + A[P − 1]) − (A[P] + A[P + 1] + ... + ..
-
시간복잡도를 고려한 알고리즘Algorithm 2021. 6. 30. 12:30
아래 문제는 코딜리티에서 제공하는 FlogJmp의 문제입니다🧑🏻💻 문제 제시 A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. Count the minimal number of jumps that the small frog must perform to reach its target. Write a function: class Solution { public int solution(in..