diff --git a/problems/mirror-reflection.cpp b/problems/mirror-reflection.cpp new file mode 100644 index 0000000..2cc82ea --- /dev/null +++ b/problems/mirror-reflection.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + int mirrorReflection(int p, int q) + { + auto lcm = p * q / std::gcd(p, q); + auto x = lcm / p; + auto y = lcm / q; + + if (x % 2 == 0) { + return 0; + } + + if (y % 2 == 0) { + return 2; + } + return 1; + } +};