-1
我需要幫助搞清楚的算法對於這個問題(在Java編碼):排序副本(JAVA)
寫一個發生在升序整數堆棧,並採取所有重複的整數的方法和把它們放在堆棧的後面,同時保持升序。例如: {1,2,2,2,2,4,5,5,7,7,7,8}變爲{1,2,4,5,7,8,2,2, 2,5,5,7,7} 注意: 你不能使用迭代器或每個循環。您只能使用push(),pop(),isEmpty()和size()。您還必須僅使用一個臨時堆棧來解決問題。
這不是作業或任何東西。它正在進行測試,我無法弄清楚。
那麼你試過什麼? –
那麼..那麼它的時間讓你去思考...... – TheLostMind
好吧,一般來說,重新排列堆疊物品是一個不容否認的問題。但無論如何,彈出每個元素,然後添加一個if語句的計數器應該解決你的這個問題。假設我已經理解了這個制定良好的問題 – user2472706