g0801_0900.s0858_mirror_reflection.Solution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
package g0801_0900.s0858_mirror_reflection;
// #Medium #Math #Geometry
public class Solution {
public int mirrorReflection(int p, int q) {
while (p % 2 == 0 && q % 2 == 0) {
p /= 2;
q /= 2;
}
if (p % 2 == 0) {
return 2;
} else if (q % 2 == 0) {
return 0;
} else {
return 1;
}
}
}