package leetcode;

/**
 * https://leetcode.com/problems/mirror-reflection/
 */
public class Problem858 {
    public int mirrorReflection(int p, int q) {
        // TODO
        if (q == 0) {
            return 0;
        }
        return 0;
    }

    public static void main(String[] args) {
        Problem858 prob = new Problem858();
        System.out.println(prob.mirrorReflection(2, 1)); // 2
        System.out.println(prob.mirrorReflection(2, 0)); // 0
        System.out.println(prob.mirrorReflection(3, 1)); // 1
        System.out.println(prob.mirrorReflection(4, 1)); // 2
        System.out.println(prob.mirrorReflection(3, 2)); // 0
        System.out.println(prob.mirrorReflection(5, 3)); // 1
    }
}

@@ -150,24 +150,8 @@
 ) %7B%0A
-        // TODO%0A
     
@@ -164,24 +164,24 @@
  (q == 0) %7B%0A
+
             
@@ -200,16 +200,42 @@
       %7D%0A
+        if (p == q) %7B%0A    
         
@@ -245,230 +245,199 @@
 urn 
-0
+1
 ;%0A
+    
     %7D%0A
-%0A
+ 
     
-public static void main(String%5B%5D args) %7B%0A        Problem858 prob = new Problem858();%0A        System.out.println(prob.mirrorReflection(2, 1)); // 2%0A        System.out.println(prob.mirrorReflection(2, 0)); //
+   int a = q;%0A        boolean right = true;%0A        boolean zero;%0A        while (true) %7B%0A            a += q;%0A            right = !right;%0A            zero = (a / p) %25 2 ==
  0
+;
 %0A   
@@ -445,247 +445,211 @@
     
-System.out.println(prob.mirrorReflection(3, 1)); // 1%0A        System.out.println(prob.mirrorReflection(4, 1)); // 2%0A        System.out.println(prob.mirrorReflection(3, 2)); // 0%0A        System.out.println(prob.mirrorReflection(5, 3)); // 1
+    if (a %25 p == 0) %7B%0A                break;%0A            %7D%0A        %7D%0A        if (right) %7B%0A            if (zero) %7B%0A                return 0;%0A            %7D%0A            return 1;%0A        %7D%0A        return 2;
 %0A   

Solve problem 858