๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ## ๋ฌธ์ : 1.10 ๋ฐฐ์ด์ ํ์ | |
| - ์ ๋ ฅ์ผ๋ก ์ ์ํ ๋ฐฐ์ด๊ณผ k ๊ฐ์ด ์ฃผ์ด์ง๋ฉด, ๊ฐ ์์๋ฅผ ์ฐ์ธก์ผ๋ก | |
| k ๋ฒ ์ด๋ ๋ฐ ํ์ ์ ํด๋ณด์. | |
| - k๋ ์์ ์ ์ ๊ฐ์ด๋ค. | |
| - ์๋ฅผ ๋ค์ด์, nums ๋ฐฐ์ด์ [1, 2, 3, 4] ๊ฐ ์๊ณ , k๊ฐ 1์ด๋ผ๋ฉด ์์๋ ์ฐ์ธก์ผ๋ก 1์นธ์ฉ | |
| ์ด๋ ๋ฐ ํ์ ํ์ฌ [4, 1, 2, 3] ์ด ๋๋ค. | |
| ## ์ ํ์ฌํญ : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| # ๋ฌธ์ 1.11 ๋น ์ง ์ซ์ ์ฐพ๊ธฐ | |
| - ์ฃผ์ด์ง ์ ์ํ ๋ฐฐ์ด์ 0 ~ n ๊น์ง์ ์ซ์๋ฅผ ๋ด๊ณ ์๋๋ฐ ์ด ์ค์ ๋น ์ง ์ซ์๋ฅผ ์ฐพ์๋ณด์. | |
| - ๋ฐฐ์ด์ ๊ฐ์ 0์์ ์์ํ์ฌ n๊น์ง n + 1๊ฐ์ ์์๋ฅผ ๊ฐ์ง ์ ์์ง๋ง, ๋ฐฐ์ด์ ํฌ๊ธฐ๋ n์ผ๋ก | |
| ์ด ์ซ์ ์ค์ ํ๋๋ ๋น ์ ธ์๋ค๋ ๋ป์ด๋ค. | |
| - ์๋ฅผ ๋ค์ด์, nums = [3, 1, 0] ์ด๋ผ๋ฉด ๋น ์ง ์ซ์๋ 2์ด๋ค. | |
| ## ์ ํ ์ฌํญ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ## ๋ฌธ์ : 1.3 ๋์์ ํฉ ์ฐพ๊ธฐ | |
| ์ฃผ์ด์ง ์ ์ํ ๋ฐฐ์ด์์ 2๊ฐ์ ์ซ์๋ฅผ ์ ํํ์ฌ, ๋ํ ๊ฐ์ด ํน์ ๋ชฉํ๊ฐ์ ๋ง๋ค๋, | |
| ๊ทธ ์ ํํ 2๊ฐ์ ์ ์๊ฐ ์๋ ๋ฐฐ์ด์ ์ธ๋ฑ์ค๋ฅผ ๋ฐํํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ๋ผ. | |
| ์ ๋ ฅ๊ฐ : nums = [2, 7, 10, 19] target = 9 | |
| ์ถ๋ ฅ๊ฐ : [0, 1] | |
| """ | |
| from typing import List |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ## ๋ฌธ์ : 1.4 | |
| - ์ ๋ ฌ๋ ๋ฐฐ์ด์ ์์๋ค์ ์ค๋ณต ์์ด, ๋จ 1๋ฒ์ฉ๋ง ๊ฐ์ง ์ ์๋๋ก ์ฃผ์ด์ง ๋ฐฐ์ด์ ๊ทธ๋๋ก ์์ ํ๊ณ , | |
| ์์ ๋ ๋ฐฐ์ด์ ์๋ก์ด ๊ธธ์ด๋ฅผ ๋ฐํํ๋ผ. | |
| """ | |
| from typing import List | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ๋ฌธ์ : ๋ฐฐ์ด์ ์๋ ์ซ์์ ์กฐํฉ์ผ๋ก ํน์ ์ซ์๋ฅผ ๋ง๋ค ์ ์๋์ง๋ฅผ ์์๋ณด๋ ๋ฌธ์ ์ด๋ค. | |
| ์ดํด๊ฐ ์ ๋์ง ์๋๋ค๋ฉด, ํ์ค ํ์ค ์ฝ ์คํ์ ๊ทธ๋ ค๋ณด๋ฉด์ ์ดํดํด๋ณด๋ ๊ฒ์ด ์ข๋ค. | |
| """ | |
| from typing import List | |
| def group_sum(nums: List[int], subset: List[bool], target: int, i: int) -> bool: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ๋ฌธ์ 1.5.1: ์ ๋ ฌ๋ ๋ฐฐ์ด๊ณผ ๋ชฉํ๊ฐ์ด ์์ ๋, ๋ฐฐ์ด์ ํด๋น ์ธ๋ฑ์ค๋ฅผ ๋ฐํํ๊ณ , | |
| ์ฐพ์ง ๋ชปํ๋ค๋ฉด, ์ ๋ ฌ๋ ๋ฐฐ์ด์ด ๋๋๋ก ๋ชฉํ๊ฐ์ด ๋ฐฐ์ด์ ๋ค์ด๊ฐ์ผ ํ๋ ์ธ๋ฑ์ค๋ฅผ | |
| ๊ตฌํ๋ ๋ฌธ์ ์ด๋ค. | |
| """ | |
| from typing import List | |
| def searchIndex(nums: List[int], target: int) -> int: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ๋ฌธ์ 1.6: ์ฃผ์ด์ง ๋ ๋ฐฐ์ด (nums1, nums2)์ ์ ๋ ฌ์ ์ ์งํ๋ฉด์ | |
| ๋ณํฉ์ ํด๋ณด์. | |
| """ | |
| from typing import List | |
| def merge(nums1: List[int], m: int, nums2: List[int], n: int) -> None: | |
| i = m - 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ๋ฌธ์ 1.7: ์ ๋ ฌ๋ ๋ฐฐ์ด nums1, nums2๊ฐ ์ฃผ์ด์ง๊ณ , ๊ฐ๊ฐ์ ํฌ๊ธฐ๋ m๊ณผ n์ด๋ค. | |
| ์ ๋ ฌ์ ์ ์งํ๋ฉด์ nums1 ๋ฐฐ์ด๋ถํฐ ์ฑ์๋๊ฐ nums2๊น์ง ํ์ฅ์ ํด๋ณด์. | |
| """ | |
| from typing import List | |
| def merge(nums1: List[int], m: int, nums2: List[int], n: int) -> List[int]: | |
| for i, nums1_item in enumerate(nums1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ๋ฌธ์ 1.13: ๊ณ ์ ํ ์ ์์ ์งํฉ์ผ๋ก ๋ฐฐ์ด์ด ์ฃผ์ด์ง๋ฉด, ๊ฐ๋ฅํ ๋ชจ๋ ๋ถ๋ถ์งํฉ์ ๋ฐํํ์. | |
| ์ค๋ณต๋ ๋ถ๋ถ์งํฉ์ ํ์ฉํ์ง ์๋๋ค. | |
| ์ ๋ ฅ์ผ๋ก [1, 2, 3]์ด ์ฃผ์ด์ง๋ฉด, ๊ฒฐ๊ณผ๋ก [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]] ์ ๋ฐํํ๋ฉด ๋๋ค. | |
| ## ์ ํ ์ฌํญ | |
| - ์ ๋ ฅ์ ๊ณ ์ ํ ์ ์์ ์งํฉ์ผ๋ก ์ด๋ฃจ์ด์ ธ์๋ค. | |
| - ์ ์ํ ๋ฐฐ์ด | |
| - ๋ฐํ๊ฐ์ 2์ฐจ์ ์ ์ํ ๋ฐฐ์ด |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ๋ฌธ์ 1.13: ๊ณ ์ ํ ์ ์์ ์งํฉ์ผ๋ก ๋ฐฐ์ด์ด ์ฃผ์ด์ง๋ฉด, ๊ฐ๋ฅํ ๋ชจ๋ ๋ถ๋ถ์งํฉ์ ๋ฐํํ์. | |
| ์ค๋ณต๋ ๋ถ๋ถ์งํฉ์ ํ์ฉํ์ง ์๋๋ค. | |
| ์ ๋ ฅ์ผ๋ก [1, 2, 3]์ด ์ฃผ์ด์ง๋ฉด, ๊ฒฐ๊ณผ๋ก [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]] ์ ๋ฐํํ๋ฉด ๋๋ค. | |
| ## ์ ํ ์ฌํญ | |
| - ์ ๋ ฅ์ ๊ณ ์ ํ ์ ์์ ์งํฉ์ผ๋ก ์ด๋ฃจ์ด์ ธ์๋ค. | |
| - ์ ์ํ ๋ฐฐ์ด | |
| - ๋ฐํ๊ฐ์ 2์ฐจ์ ์ ์ํ ๋ฐฐ์ด |