文章
7
粉丝
204
获赞
4
访问
67.9k
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
String str = cin.next();
Queue<Character> q = new LinkedList<Character>();
for (int i = 0; i < str.length(); i++)
q.offer(str.charAt(i));
Node node = StringToTree(q);
System.out.println(istt(node) == true ? "YES" : "NO");
}
static boolean istt(Node node) {
if (node == null)
return true;
return istt(node.left, node.right);
}
static boolean istt(Node left, Node right) {
if (left == null && right == null)
return true;
if (left == null || right == null)
return false;
return istt(left.left, right.right) && istt(left.right, right.left);
}
public static Node StringToTree(Queue<Character> q) {
char s = q.poll();
if (s == '#')
return null;
Node head = new Node(s);
Queue<Node> queue1 = ne...
登录后发布评论
暂无评论,来抢沙发