Algorithm
-
LeetCode - Patching ArrayAlgorithm 2021. 12. 10. 20:32
์๋ ํ์ธ์. ๊ทธ๋ฆฐ์ ๋๋ค๐ข ์ด๋ฒ ํฌ์คํ ์์๋ ์ค๋๋ง์ ์๊ณ ๋ฆฌ์ฆ์ ํ๋ ํ์ด๋ณผ๊นํฉ๋๋ค. ์ด๋ฒ์๋ LeetCode์์ Patching Array๋ผ๋ ๋ฌธ์ ๋ฅผ ํ์ด๋ดค์ด์! ๋ฌธ์ ์ ์ Given a sorted integer array nums and an integer n, add/patch elements to the array such that any number in the range [1, n] inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required. Example 1: Input: nums = [1,3], n = 6 Output: 1 Explanation: Com..
-
ํฉ์ ์ด์ฉํ ์๊ณ ๋ฆฌ์ฆAlgorithm 2021. 8. 29. 11:55
์๋ ๋ฌธ์ ๋ ์ฝ๋๋ฆฌํฐ์์ ์ ๊ณตํ๋ Passing Cars์ ๋ฌธ์ ์ ๋๋ค๐ง๐ป๐ป ๋ฌธ์ ์ ์ A non-empty array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road. Array A contains only 0s and/or 1s: - 0 represents a car traveling east - 1 represents a car traveling west. The goal is to count passing cars. We say that a pair of cars (P, Q), where 0 ≤ P < Q < N, is passing when P 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..