import Stack from './Stack' ; param { Array } pushOrder param { Array } popOrder return { Boolean } function StackCheck < T > ( pushOrder , popOrder ) { if ( pushOrder . length !== popOrder . length ) { return false ; } const stack = new Stack ( ) ; let push = 0 , pop = 0 ; while ( pop < popOrder . length ) { for ( ; push < pushOrder . length && popOrder [ pop ] !== stack . peek ( ) ; push ++ ) { stack . push ( pushOrder [ push ] ) ; } if ( popOrder [ pop ] !== stack . peek ( ) ) { return false ; } stack . pop ( ) ; pop ++ ; } return true ; } export default StackCheck ;