leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0991.cpp (334B)
0 class Solution { 1 public: 2 int brokenCalc(const int startValue, int target) const { 3 int res = 0; 4 while (target > startValue) { 5 res++; 6 if (target % 2 == 0) 7 target /= 2; 8 else 9 target++; 10 } 11 return res + (startValue - target); 12 } 13 };