Title: Flip integer 123--> 321, -123--> -321
Problem solution: long long look good memory, attention overflow return 0 on the line
class Solution { public: int reverse(int x) { long long orix = x; long long rev = 0; bool isLess0 = orix < 0; orix = orix < 0 ? -1 * orix : orix; while(orix != 0){ rev = rev * 10 + (orix % 10); orix /= 10; } if (isLess0){ rev *= -1; } long long minm = (-1) * (1 << 31); long long maxm = (1 << 31) - 1; if (rev < minm || rev > maxm){ return 0; }else{ return rev; } } };