I was solving a problem, where I was given a string and Q queries (1<=Q<=10^5). And each query was of the type- String S Integer X , where S can be “Left” or “Right” denoting left shift and Right shift operation and X represents, the units by which I have to shift.
I used this GFG Code, but it gave me TLE in 2 test cases. But when I did the same using python slicing, it passed the tests.
So, is string operations fast on python?
2 Likes
Read this: Why is splitting a string slower in C++ than Python? - Stack Overflow
Hope it’ll help you!
3 Likes
Thanks. Got it
1 Like
Its known that Python is inherently slower but CodeChef could be having different time limits for diff languages. On this, pls check below :-
1 Like
generally inbulit operations are made very much optimised.
1 Like
Codechef does have different time limits
for a solution in C/C++ Codechef usually gives TLE only after 1 sec but it gives TLE in java after 2 secs
Some naive codes work in one language but give TLE in the other is because of different speeds of doing certain operations
Your case is an example of it
Pls Like
1 Like