1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00

problems: add mirror reflection

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-08-04 21:35:42 +02:00
parent 08a623bb50
commit 826b402dd1
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -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;
}
};