leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1033.cpp (305B)


      1 class Solution {
      2   public:
      3     vector<int> numMovesStones(int a, int b, int c) const {
      4         if (a > b) swap(a, b);
      5         if (a > c) swap(a, c);
      6         if (b > c) swap(b, c);
      7 
      8         if (a + 1 == b && b + 1 == c) return {0, 0};
      9         return {b - a <= 2 || c - b <= 2 ? 1 : 2, c - a - 2};
     10     }
     11 };