[Python] ๋ณ‘ํ•ฉ์ •๋ ฌ
ยท
Algorithm/Python
๋ณ‘ํ•ฉ์ •๋ ฌ ๋ฐ์ดํ„ฐ์˜ ์š”์†Œ๋“ค์„ ๋‘ ๊ทธ๋ฃน์œผ๋กœ ๋‚˜๋ˆˆ ํ›„ ์ •๋ ฌํ•˜๊ณ , ์ •๋ ฌ๋œ ๋‘ ๊ทธ๋ฃน์„ ๋น„๊ตํ•˜๋ฉฐ ํ•˜๋‚˜๋กœ ํ•ฉ์น˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. ๋ณ‘ํ•ฉ์ •๋ ฌ๊ณผ์ • #์ˆซ์ž 8๊ฐœ๋ฅผ ๋ฐ˜์œผ๋กœ ๋‚˜๋ˆˆ๋‹ค group1 = [2, 8, 4, 7] group2 = [6, 1, 3, 5] #๋‘ ๊ทธ๋ฃน์„ ์ •๋ ฌํ•œ๋‹ค. group1 = [2, 4, 7, 8] group2 = [1, 3, 5, 6] #๋‘ ๊ทธ๋ฃน์„ ํ•˜๋‚˜์˜ ๊ทธ๋ฃน์œผ๋กœ ํ•ฉ์นœ๋‹ค. ๋‘ ๊ทธ๋ฃน์˜ ์ฒซ๋ฒˆ์งธ ๊ฐ’์„ ๋น„๊ตํ•ด ์ž‘์€ ๊ฐ’์„ ์ƒˆ๋กœ์šด ๋ฆฌ์ŠคํŠธ(result)์— ๋„ฃ๋Š”๋‹ค. group1 = [2, 4, 7, 8] group2 = [3, 5, 6] result = [1] #๋‘ ๊ทธ๋ฃน์˜ ์ฒซ๋ฒˆ์งธ ๊ฐ’์„ ๋น„๊ตํ•ด ์ž‘์€ ๊ฐ’์„ ์ƒˆ๋กœ์šด ๋ฆฌ์ŠคํŠธ์— ๋„ฃ๋Š” ๊ฒƒ์„ ๋ฐ˜๋ณตํ•œ๋‹ค. group1 = [4, 7, 8] group2 = [3, 5, 6] result ..