Are they the same problem

I followed the methodology shown in the tutorial video. But I am getting TLE in 3 out of 4 test cases. Here is my code: https://ide.codingblocks.com/s/243590

@a_krisna22 using for loop to divide the array in two parts is not an efficient approach, use string to store s1 and s2 then divide them in two parts using string.substr().

Thanks its working now, But doesnt

Thanks its working now, but doesn’t the string class function substr take o(n) time itself. So why does loops which also take o(n) time give TLE?