๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ์ธ๊ณต๋ถ€/Algorithm

[Level 1] ์„œ์šธ์—์„œ ๊น€์„œ๋ฐฉ ์ฐพ๊ธฐ

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2021. 4. 23.

 

 

 

Algorithm

-  ์„œ์šธ์—์„œ ๊น€์„œ๋ฐฉ ์ฐพ๊ธฐ -

 


 

๋ฌธ์ œ

Stringํ˜• ๋ฐฐ์—ด seoul์˜ element์ค‘ "Kim"์˜ ์œ„์น˜ x๋ฅผ ์ฐพ์•„ "๊น€์„œ๋ฐฉ์€ x์— ์žˆ๋‹ค"๋Š” String์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•˜์„ธ์š”.

seoul์— "Kim"์€ ์˜ค์ง ํ•œ ๋ฒˆ๋งŒ ๋‚˜ํƒ€๋‚˜๋ฉฐ ์ž˜๋ชป๋œ ๊ฐ’์ด ์ž…๋ ฅ๋˜๋Š” ๊ฒฝ์šฐ๋Š” ์—†์Šต๋‹ˆ๋‹ค.

 

์ž…์ถœ๋ ฅ ์˜ˆ์‹œ

seoul return
["Jane", "Kim"] "๊น€์„œ๋ฐฉ์€ 1์— ์žˆ๋‹ค."

 

๋ฌธ์ œ ํ’€๊ธฐ

 

์ด๋ฒˆ๋ฌธ์ œ๋Š” ๊นŒ๋‹ค๋กœ์šด ์กฐ๊ฑด์—†์ด ๊ทธ๋ƒฅ ๋ฐฐ์—ด์•ˆ์— "Kim"์ด๋ผ๋Š” ๋ฌธ์ž์˜ ์ธ๋ฑ์Šค ์œ„์น˜๋งŒ ์ฐพ์œผ๋ฉด ๋˜๋Š” ๋ฌธ์ œ์˜€๊ธฐ ๋•Œ๋ฌธ์— ๋ณ„ ์–ด๋ ค์›€ ์—†์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•ด ๋‚˜๊ฐˆ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€