Here it is: CHFDORA Solution - CodeChef January Long Challenge 2020 - YouTube
Commented code:
CodeChef: Practical coding for everyone O((nm)^1.5)
CodeChef: Practical coding for everyone O(nm)
To solve in O(nm):
Programming Problems and Competitions :: HackerRank
Manacher's Algorithm - Linear Time Longest Palindromic Substring - Part 1 - GeeksforGeeks
Comments, questions, requests, criticism, are all welcome!
Hey! In my code only 1 test case gives TLE… plz help which edge case i am missing
You should loop for length inside of the loop for i, j and break when SIc >= 0 && EIc <m && SIr >= 0 && EIr <n
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
int SIc = j-(length/2);
int EIc = j+(length/2);
int SIr = i-(length/2);
int EIr = i+(length/2);
if (SIc >= 0 && EIc <m && SIr >= 0 && EIr <n){
boolean a = checkpallindromec(arr,SIc,EIc,i);
if (a == true){
boolean b = checkpallindromer(arr,SIr, EIr,j);
if (a == true && b== true) pairs++;
}
}
}
}
length +=2;
here, it would enter if statement only when the conditions u mentioned are true,… why and where to add a break statement…
i am not getting u …
Actually, never mind what I said about the loops. Simply set endp in your code to Math.min(n, m).
whats endp !?
The variable endp in your code.
it did give correct ans… thankss
But what was wrong … as in why was that 1 test case was giving TLE !?
And also, how did u come up with this error …
You need min(n, m) instead of m to guarantee that the time complexity of the solution is good
Ohkk… Got it now… Thanks
No problem
Unfortunately, Python is slow for big inputs…
Most submissions which obtain 100 (CodeChef: Practical coding for everyone) run close to the time limit.
thanks bro …my bad
No problem. The good thing about long challenges is that you have a lot of time to rewrite solutions in another language if you need to.
Submit using PYPY3 it will work.