implementation of Stoi function can be seen here
what is time complexity of above mentioned stoi function?
implementation of Stoi function can be seen here
what is time complexity of above mentioned stoi function?
The time complexity of std::stoi
is unspecified. A conforming implementation can use any algorithm that eventually generates the correct result.
As a quality-of-implementation issue, it will probably do a linear scan through at most logbase(INT_MAX
) + 3 digits, which is bounded above by sizeof(int) * CHAR_BIT
. That's O(1), but there might be any amount of preceding whitespace, so it's probably O(str.size()
)