runtime error,help me


  • 0
    H

    class Solution {
    public:
    int reverse(int x) {
    if(x<0)
    {
    return -reverse(-x);
    }
    else
    {
    vector < int > a;

            do
            {
                a.push_back(x%10);
                x=x/10;
            }while(x!=0);
            int c=0;
            
            for(int i=0;i<a.size();i++)
            {
                c*=10;
                c+=a[i];
            }
            return c;
        }
    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.