aboutsummaryrefslogtreecommitdiff
path: root/mirror_reflection.cpp
blob: 447ce5efee924f5a6c688a34441cb0abe149a569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "leetcode.h"

class Solution {
public:
  int mirrorReflection(int p, int q) {
    while ((p % 2 == 0) && (q % 2 == 0)) {
      p /= 2;
      q /= 2;
    }
    if ((p % 2) == 0 && (q % 2) != 0)
      return 2;
    if ((p % 2) != 0 && (q % 2) != 0)
      return 1;
    return 0;
  }
};

int main() {
  Solution obj;
  cout << obj.mirrorReflection(2, 1);
}