Skip to content

Commit 289c07e

Browse files
committed
comments
1 parent b487b4e commit 289c07e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

โ€Žcontains-duplicate/bus710.goโ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
// ์ฃผ์–ด์ง„ ๋ฐฐ์—ด์„ ์„ ํ˜• ์ˆœํšŒ ํ•˜๋ฏ€๋กœ, ์‹œ๊ฐ„ ๋ณต์žก๋„์™€ ๊ณต๊ฐ„ ๋ณต์žก๋„ ๋ชจ๋‘ O(n)์ผ ๊ฒƒ์œผ๋กœ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
2+
13
package week01
24

5+
// ์ฃผ์–ด์ง„ ๋ฐฐ์—ด nums๋ฅผ ์ˆœํšŒํ•˜๋ฉฐ ์ค€๋น„ํ•œ ๋งต์— ํ‘œ์‹œ๋ฅผ ํ•˜๋˜,
6+
// - ํ‚ค๊ฐ’์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’์ด ์—†์œผ๋ฉด ๋งต์˜ ํ•ด๋‹น ํ‚ค๊ฐ’์— true๋ฅผ ์ €์žฅํ•˜๊ณ 
7+
// - ํ‚ค๊ฐ’์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’์ด ์žˆ์œผ๋ฉด ์ฆ‰์‹œ true๋ฅผ ๋ฐ˜ํ™˜.
8+
// - ์ˆœํšŒ ํ›„์—๋„ ๋ฐ˜ํ™˜ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ์ค‘๋ณต์ด ๋ฐœ๊ฒฌ๋˜์ง€ ์•Š์•˜์œผ๋ฏ€๋กœ false๋ฅผ ๋ฐ˜ํ™˜.
39
func containsDuplicate(nums []int) bool {
410
dup := make(map[int]bool, 0)
511
for _, n := range nums {

0 commit comments

Comments
ย (0)