ํ๋ก๊ทธ๋๋จธ์ค
[ํ๋ก๊ทธ๋๋จธ์ค] ์ฃผ์ ๊ฐ๊ฒฉ ํ์ด
์ฃผ์๊ฐ๊ฒฉ ๋ฌธ์ ์คํ 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(..