This is a very basic problem of implementing a queue operation using two stacks.
TillUntil now there are no issues with the logic but the testing tool report it takes more time than usual.
The test tool expects it to be completed by 10seconds10 seconds.
TriedI tried with both pythonPython way and traditional algorithmic way but both did not help.
Could I could not find much content with pythonPython list optimization that I can map here.
Qora link.
Quora link
StackOverflow link.
Stack Overflow link
Listed two of the implementations for reference.:
Try - 1:
Try 1:
Try - 2:
Try 2:
NotI'm not able to understand if append, insert or pop is taking more time.
(Would pre-allocated array of specified size help in pythonPython?)
Note-: The testing tool is from a web based platform for developers to practice coding.
I I am making this question for suggestions about optimization that may help here.