[Algorithm]

hyena_leeยท2023๋…„ 3์›” 6์ผ
0

Algorithm

๋ชฉ๋ก ๋ณด๊ธฐ
49/53
post-thumbnail

๐Ÿฆ• ๋ฌธ์ž์—ด ๋ฐ€๊ธฐ

๐Ÿ€ ๋ฌธ์ œ ํ’€์ด

๐ŸŒฒ ํšŒ๊ณ 

๋ฌธ์ž์—ด์ด ๊ฐ™์œผ๋ฉด 0์„ ๋ฆฌํ„ดํ•˜๊ณ  ๊ธฐ๋ณธ ๋ฌธ์ž์—ด ๋์—์„œ ์ œ๊ฑฐํ›„ ์•ž์— ๋๋ฌธ์ž๋ฅผ ๊ฐ–๋‹ค ๋ถ™์ธ๋‹ค.
for loop ๋Œ๋ ค -1 ๋ฆฌํ„ดํ•˜๋Š” ์‹์œผ๋กœ ๋ฑ…๋ฑ…๊ผฌ์•„์„œ ํ’€๊ธด ํ–ˆ์ง€๋งŒ ๋‹ค๋ฅธ ์‚ฌ๋žŒ ์ฝ”๋“œ ๋ณด๊ณ  ๋„ˆ๋ฌด ๋†€๋ž๋‹ค.

let solution = (a, b) => (b+b).indexOf(a)
// ๋ฏผ ๋ฌธ์ž์—ด์„ ๋”ํ•œ๊ฐ’์— ๋ช‡๋ฒˆ์งธ์— a ๊ฐ€ ์žˆ๋Š”์ง€ ์ฐพ๊ณ , ์—†์œผ๋ฉด -1 ๋ฆฌํ„ด...

๋„๋Œ€์ฒด ๋‚˜ ๋ญ์˜€์ง€...์™œ ๊ธฐ๋ณธ๊ธฐ๊ธฐ๋ณธ๊ธฐ ํ•˜๋Š”์ง€ ์•Œ์ •๋„๋กœ...์ด๋ฒˆ์ฃผ๋Š” ๊ฐœ๋… ๋‹ค์‹œ ๋‹ค์ ธ์•ผ์ง€...

profile
์‹ค์ˆ˜๋ฅผ ๋‘๋ ค์›Œ ๋ง๊ณ  ๊ณ„์† ๋„์ „ ํ•˜๋Š” ๊ฐœ๋ฐœ์ž์˜ ์—ฌ์ •!

0๊ฐœ์˜ ๋Œ“๊ธ€