์ฝ”๋”ฉํ…Œ์ŠคํŠธ

    [ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ฃผ์‹ ๊ฐ€๊ฒฉ ํ’€์ด

    ์ฃผ์‹๊ฐ€๊ฒฉ ๋ฌธ์ œ ์Šคํƒ Last In First Out(LIFO), ๋‚˜์ค‘์— ๋“ค์–ด๊ฐ„ ์›์†Œ๊ฐ€ ๋จผ์ € ๋‚˜์˜ด push: ์Šคํƒ์— ์Œ“์Œ pop: ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰์— ๋“ค์–ด๊ฐ„ ์›์†Œ๋ฅผ ์ œ๊ฑฐํ•˜๋ฉฐ ๋ฐ˜ํ™˜ ํŒŒ์ด์ฌ ํ’€์ด def solution(prices): st=[] answer = [0]*len(prices) for i in range(len(prices)): if st == []: st.append(i) continue else: if prices[i] >= prices[i-1]: st.append(i) else: while prices[i] < prices[i-1] : top = st.pop() answer[top] = i-top if st == []: st.append(i) break top = st.pop() st.append(..