leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1017.cpp (261B)
0 class Solution { 1 public: 2 string baseNeg2(int n) { 3 if (n == 0) return "0"; 4 string res; 5 do { 6 res += to_string(n & 1); 7 } while ((n = -(n >> 1))); 8 reverse(begin(res), end(res)); 9 return res; 10 } 11 };