From 33bbe6b04c3550aab73cf3b0e97c7b0957ace434 Mon Sep 17 00:00:00 2001 From: paul-killer <40170380+paul-killer@users.noreply.github.com> Date: Wed, 14 Oct 2020 14:18:48 +0530 Subject: [PATCH 1/2] Create solution.h Have not added any Readme file since Readme files are in different language. Since main Readme file doesn't contain this problem, I have labeled it as 711. --- solution.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 solution.h diff --git a/solution.h b/solution.h new file mode 100644 index 0000000..a19ae6f --- /dev/null +++ b/solution.h @@ -0,0 +1,65 @@ +class Solution { +public: + bool isOverflow(long long a, long long b){ + long long res=a*10+b-48; + if(res>INT_MAX) + return true; + return false; + } + + int myAtoi(string s) { + int c=0; + bool isminus=0; + bool nostart=0; + for(int i=0;i57){ + break; + } + else{ + nostart=1; + if(isOverflow(c,s[i])){ + if(isminus){ + c=INT_MIN; + isminus=0; + } + else{ + c=INT_MAX; + } + break; + } + + else{ + c=c*10+(s[i]-48); + } + + } + } + + if(isminus){ + c=c*-1; + } + + return c; + } +}; From 17f48124e4085c2a8905b34c7e4efc72e9736235 Mon Sep 17 00:00:00 2001 From: paul-killer <40170380+paul-killer@users.noreply.github.com> Date: Wed, 14 Oct 2020 14:23:39 +0530 Subject: [PATCH 2/2] Delete solution.h --- solution.h | 65 ------------------------------------------------------ 1 file changed, 65 deletions(-) delete mode 100644 solution.h diff --git a/solution.h b/solution.h deleted file mode 100644 index a19ae6f..0000000 --- a/solution.h +++ /dev/null @@ -1,65 +0,0 @@ -class Solution { -public: - bool isOverflow(long long a, long long b){ - long long res=a*10+b-48; - if(res>INT_MAX) - return true; - return false; - } - - int myAtoi(string s) { - int c=0; - bool isminus=0; - bool nostart=0; - for(int i=0;i57){ - break; - } - else{ - nostart=1; - if(isOverflow(c,s[i])){ - if(isminus){ - c=INT_MIN; - isminus=0; - } - else{ - c=INT_MAX; - } - break; - } - - else{ - c=c*10+(s[i]-48); - } - - } - } - - if(isminus){ - c=c*-1; - } - - return c; - } -};