[Python] ์„ ํƒ์ •๋ ฌ
ยท
Algorithm/Python
์„ ํƒ์ •๋ ฌ ๋ฐ์ดํ„ฐ์—์„œ ์ตœ์†Ÿ๊ฐ’์„ ์ฐพ์•„ ๊ทธ ๊ฐ’๊ณผ ๋ฒ”์œ„์˜ ๋งจ ์•ž์— ์žˆ๋Š” ๊ฐ’์„ ์„œ๋กœ ๋ฐ”๊พธ๋Š” ๊ณผ์ •์„ ๋ฐ˜๋ณตํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. ์„ ํƒ์ •๋ ฌ ๊ณผ์ • ์˜ˆ๋ฅผ ๋“ค์–ด [2, 4, 5, 1, 3] ๊ฐ€ ์žˆ์„ ๋•Œ, ๊ฐ€์žฅ ์ž‘์€ ๊ฐ’์„ ์ฐพ์•„ ์ฒซ๋ฒˆ์งธ ๊ฐ’๊ณผ ๊ทธ ๊ฐ’์„ ๋ฐ”๊พผ๋‹ค. (์ด๋ฏธ ์ •๋ ฌ ์™„๋ฃŒ๋œ ๊ฐ’์€ | ๋กœ ๊ตฌ๋ถ„ํ•œ๋‹ค.) [2, 4, 5, 1, 3] # ๊ฐ€์žฅ ์ž‘์€ ๊ฐ’ : 1 ์ฒซ๋ฒˆ์งธ ๊ฐ’ : 2 [1 | 4, 5, 2, 3] # ๊ฐ€์žฅ ์ž‘์€ ๊ฐ’ : 2 ์ฒซ๋ฒˆ์งธ ๊ฐ’ : 4 [1, 2 | 5, 4, 3] # ๊ฐ€์žฅ ์ž‘์€ ๊ฐ’ : 3 ์ฒซ๋ฒˆ์งธ ๊ฐ’ : 5 [1, 2, 3 | 4, 5] # ๊ฐ€์žฅ ์ž‘์€ ๊ฐ’ : 4 ์ฒซ๋ฒˆ์งธ ๊ฐ’ : 4 //๋ณ€ํ™”์—†์Œ [1, 2, 3, 4 | 5] # ์ž๋ฃŒ๊ฐ€ 5 ํ•˜๋‚˜๋งŒ ๋‚จ์Œ. ์ข…๋ฃŒ ๊ฒฐ๊ณผ [1, 2, 3, 4, 5] ์„ ํƒ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ def sel_..