题解 | 好串
好串
https://www.nowcoder.com/practice/9b072237ebdd4dd99562f01cbf594fac
import java.util.Scanner;
import java.util.Stack;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
Stack<Character> stack = new Stack<>();
for(Character c : s.toCharArray()){
if( !stack.isEmpty() && stack.peek() == 'a' && c == 'b'){
stack.pop();
}else{
stack.push(c);
}
}
System.out.println(stack.isEmpty() ? "Good" : "Bad");
}
}

