Divide Integers Time : Space : 1234567891011121314151617181920212223242526int Solution::divide(int A, int B) { if(B == 0) return INT_MAX; long long sign = 1ll * A * B > 0 ? 1 : - 1; long long rem = 0, res = 0; long long a = A, b = B; a = abs(a), b = abs(b); if(a < b) return 0; string s = to_string(a); for(int i = 0; i < s.length(); i++) { long long r = 0, rres = 0; for(int j = 0; j < 10; j++) { r += rem; rres += res; } r += s[i] - '0'; while(r >= b) { r -= b; rres += 1; } rem = r; res = rres; } return sign * res >= INT_MAX ? INT_MAX : sign * res;}