코딜리티
-
FlogRiverOne 알고리즘Algorithm 2021. 7. 18. 10:45
아래 문제는 코딜리티에서 제공하는 FlogRiverOne의 문제입니다🧑🏻💻 문제 제시 A small frog wants to get to the other side of a river. The frog is initially located on one bank of the river (position 0) and wants to get to the opposite bank (position X+1). Leaves fall from a tree onto the surface of the river. You are given an array A consisting of N integers representing the falling leaves. A[K] represents the position wher..
-
시간복잡도를 고려한 알고리즘 (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] + ... + ..
-
시간복잡도를 고려한 알고리즘 (2)Algorithm 2021. 7. 7. 21:56
아래 문제는 코딜리티에서 제공하는 permMissingElem의 문제입니다🧑🏻💻 문제 제시 An array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing. Write a function: public func solution(_ A : inout [Int]) -> Int that, given an array A, returns the value of the missing element. For example, given array A such that: A[0] = 2 A[1] = 3..
-
시간복잡도를 고려한 알고리즘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..
-
중복 인덱스를 활용한 알고리즘Algorithm 2021. 6. 29. 14:36
아래 문제는 코딜리티에서 제공하는 OddOccurrencesInArray의 문제입니다🧑🏻💻 문제 제시 A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired. For example, in array A such that: A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9 the e..
-
배열을 이용한 알고리즘Algorithm 2021. 6. 28. 12:12
아래 문제는 코딜리티에서 제공하는 CyclicRotation의 문제입니다🧑🏻💻 문제 제시 An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is moved to the first place). The goal i..
-
진수변환과 문자열 인덱스를 통한 알고리즘Algorithm 2021. 6. 22. 14:15
아래 문제는 코딜리티에서 제공하는 Binary Gap의 문제입니다🧑🏻💻 문제 제시 A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 ..
-
더블 하노이 알고리즘Algorithm 2021. 6. 21. 11:22
아래 문제는 코딜리티에서 제공하는 더블 하노이의 문제입니다🧑🏻💻 문제 제시 You are given N disks and two rods, each with one initial disk. On the left rod, disks can be placed in decreasing order of size (smaller disks on top of bigger ones). On the right rod, disks can be placed in increasing order of size (bigger disks on top of smaller ones). Note that it is not permissible to place two disks of equal size on top of each ot..