Need a help

If the length of the string is 10^100000, how much time will it take to traverse the entire string ? Will this program be completed under a second ?

for eg::

string s ;

cin>>s; // length of s could be upto 10^100000

for (int i=0; i<s.length(); i++) do some O(1) operation

It would TLE of course, moreover I doubt such huge string would be given an input. Can you share the problem link?

2 Likes

Here is the link to that question → CHEFPDIG Problem - CodeChef
Basically, it is the huge number , so I consider it as string.

From the constraints:

1\le N\le 10^{100000}

So the length of the string representing N will be 100000, not 10^{100000} :slight_smile:

2 Likes

Thanks for your help.

1 Like