์๊ณ ๋ฆฌ์ฆ
-
์ํ๋ฅผ ์ต์ํํ ์๊ณ ๋ฆฌ์ฆ (2)Algorithm 2021. 8. 1. 10:53
์๋ ๋ฌธ์ ๋ ์ฝ๋๋ฆฌํฐ์์ ์ ๊ณตํ๋ MissingInteger์ ๋ฌธ์ ์ ๋๋ค๐ง๐ป๐ป ๋ฌธ์ ์ ์ This is a demo task. Write a function: public func solution(_ A : inout [Int]) -> Int that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. Given A = [1, 2, 3], the function should return 4. Given A = [−1, −3]..
-
์ํ๋ฅผ ์ต์ํํ ์๊ณ ๋ฆฌ์ฆAlgorithm 2021. 7. 24. 11:29
์๋ ๋ฌธ์ ๋ ์ฝ๋๋ฆฌํฐ์์ ์ ๊ณตํ๋ MaxCounters์ ๋ฌธ์ ์ ๋๋ค๐ง๐ป๐ป ๋ฌธ์ ์ ์ You are given N counters, initially set to 0, and you have two possible operations on them: increase(X) − counter X is increased by 1, max counter − all counters are set to the maximum value of any counter. A non-empty array A of M integers is given. This array represents consecutive operations: if A[K] = X, such that 1 ≤ X ≤ N, then operation K is..
-
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..