萌新程序员 @ 2021-10-13 21:56:23
package pac1;
import java.util.Scanner;
import java.util.Stack;
class Operate {
public void seek(int[] pushed, int[] poped, int b){
Stack<Integer> stack=new Stack<Integer>();
for(int j=0;j<b;j++){
stack.push(pushed[j]);
}
for(int i=0;i<b;i++){
if(stack.peek()==poped[i]){
stack.pop();
}
}
if(stack.empty()){
System.out.println("Yes");
}
else{
System.out.println("No");
}
}
}
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a;
int b;
//询问次数
a= sc.nextInt();
//序列长度
for(int k=0;k<a;k++) {
b = sc.nextInt();
int[] pushed = new int[b];
int[] poped = new int[b];
for (int j = 0; j < b; j++) {
pushed[j] = sc.nextInt();
}
for (int i = 0; i < b; i++) {
poped[i] = sc.nextInt();
}
Operate op = new Operate();
op.seek(pushed, poped, b);
}
return;
}
}
by rpmcppAFOed @ 2021-12-05 16:21:03
在这边大多数写C++。
by dekw赤星尘 @ 2022-04-03 10:07:11
哎,我这也是全re。兄弟你解决了吗?