title: Stack Permutations Check If An Array Is Stack Permutation Of Other
signature: def stackPermutationsCheckIfAnArrayIsStackPermutationOfOther(ip: List[Int], op: List[Int], n: Int) = {
source_py: def stack_permutations_check_if_an_array_is_stack_permutation_of_other(ip, op, n):
      Input = Queue()
      for i in range(n):
          Input.put(ip[i])
      output = Queue()
      for i in range(n):
          output.put(op[i])
      tempStack = []
      while (not Input.empty()):
          ele = Input.queue[0]
          Input.get()
          if (ele == output.queue[0]):
              output.get()
              while (len(tempStack) != 0):
                  if (tempStack[(- 1)] == output.queue[0]):
                      tempStack.pop()
                      output.get()
                  else:
                      break
          else:
              tempStack.append(ele)
      return (Input.empty() and (len(tempStack) == 0))
source_cpp: bool stack_permutations_check_if_an_array_is_stack_permutation_of_other(vector<int> ip, vector<int> op, int n) {
    queue < int > input;
    for ( int i = 0;
    i < n;
    i ++ ) input . push ( ip [ i ] );
    queue < int > output;
    for ( int i = 0;
    i < n;
    i ++ ) output . push ( op [ i ] );
    stack < int > tempStack;
    while ( ! input . empty ( ) ) {
      int ele = input . front ( );
      input . pop ( );
      if ( ele == output . front ( ) ) {
        output . pop ( );
        while ( ! tempStack . empty ( ) ) {
          if ( tempStack . top ( ) == output . front ( ) ) {
            tempStack . pop ( );
            output . pop ( );
          }
          else break;
        }
      }
      else tempStack . push ( ele );
    }
    return ( input . empty ( ) && tempStack . empty ( ) );
  }