Using inbuilt functions


#1
int Solution::reverse(int A) {
    string temp = to_string(A>=0?A:-A);
    std::reverse(temp.begin(),temp.end());
    int at = 0;
    while(temp[at]=='0') {
        at++;
    }
    temp = temp.substr(at,temp.size()-at);
    if(A<0) {
        temp.insert(temp.begin(),'-');
    }
    int answer= atoi(temp.c_str());
    string temp2 = to_string(answer);
    if(temp!=temp2) {
        return 0;
    } else {
        return answer;
    }
}