Advertisement
AlexG2230954

Untitled

Mar 22nd, 2023 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. Stack.push(el) = {
  2. buff = Queue()
  3. buff.push(el)
  4.  
  5. while(!q.empty())
  6. buff.push(q.pop())
  7.  
  8. q = buff
  9. }
  10.  
  11. Stack.pop = q.pop()
  12.  
  13. Stack.top = q.front()
  14.  
  15. Stack.max = {
  16. buff = Queue()
  17. max_el = null
  18.  
  19. while(not q.empty()) {
  20. el = q.pop()
  21. if(max_el is null or max_el < el)
  22. max_el = el
  23. buff.push(el)
  24. }
  25.  
  26. q = buff
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement