@@ -0,0 +1,994 @@
+/**%0A * Company%0A * Copyright (C) 2014-2017 All Rights Reserved.%0A */%0Apackage com.cwenao.trying.stackandqueue;%0A%0Aimport java.util.Stack;%0A%0A/**%0A *%0A * @author cwenao%0A * @version $Id CelebrityProblemByStack.java, v 0.1 2017-10-03 12:59 cwenao Exp $$%0A */%0Apublic class CelebrityProblemByStack %7B%0A%0A    private static final int%5B%5D%5B%5D MARKED = %7B%7B0, 0, 1, 0%7D, %7B0, 0, 1, 0%7D, %7B0, 0, 0, 0%7D, %7B0, 0, 1, 0%7D%7D;%0A%0A    private boolean isKnown(int a, int b) %7B%0A        return MARKED%5Ba%5D%5Bb%5D == 1;%0A    %7D%0A%0A    public int findCelebrity(int n) %7B%0A        Stack%3CInteger%3E stack = new Stack%3C%3E();%0A        int c;%0A%0A        for (int i = 0; i %3C n; i++) %7B%0A            stack.push(i);%0A        %7D%0A        while (!stack.isEmpty() && stack.size() %3E 1) %7B%0A%0A            int a = stack.pop();%0A            int b = stack.pop();%0A            if (isKnown(a, b)) %7B%0A                stack.push(b);%0A            %7D else %7B%0A                stack.push(a);%0A            %7D%0A        %7D%0A        c = stack.pop();%0A%0A        for (int i = 0; i %3C n; i++) %7B%0A%0A        %7D%0A%0A    %7D%0A%0A%7D%0A

add the celebrity problem