You are viewing a single comment's thread. Return to all comments →
can u explain if the n is string how u are converting it in int
use function stoi( )
using ASCII, Since all numerical characters will be in series in ASCII table. eg. '9' - '0' = 9 and so on
using ASCII value like this : (int)s[i]-'0'
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
can u explain if the n is string how u are converting it in int
use function stoi( )
using ASCII, Since all numerical characters will be in series in ASCII table. eg. '9' - '0' = 9 and so on
using ASCII value like this : (int)s[i]-'0'