Created
December 17, 2014 08:11
-
-
Save ik11235/889db55a1fac43a4918c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;} | |
class ForgetfulAddition { | |
public: | |
int minNumber(string expression) { | |
int ans=9999999; | |
for(int i=1;i<expression.size();i++) | |
{ | |
string a=expression.substr(0,i); | |
string b=expression.substr(i); | |
// cerr<<a<<"+"<<b<<endl; | |
ans=min(ans,toInt(a)+toInt(b)); | |
} | |
return ans; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment