class Solution {
public:
int mySqrt(int x) {
int s=0;
int e=x;
int ans=-1;
while(s<=e){
int mid=(s+e)/2;
if(midmid==x){
return mid;
}
if(midmid<x){
ans=mid;
s=mid+1;
}
else{
e=mid-1;
}
}
return ans;
}
};
this is my code and i am getting error on submit it on leetcode
Line 9: Char 19: runtime error: signed integer overflow: 1073697799 * 1073697799 cannot be represented in type ‘int’ (solution.cpp)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior prog_joined.cpp:18:19