You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, this repo you have made has helped me a lot, because I get the logic but when it comes to coding it, it sometimes feels difficult, so thank you for making this amazing repo 🙌🙌.
just pass the string with reference(&) in both the function ( isPallindrome and Solve) and it will not give TLE .
Just wanted to help, because I think there would be a lot of people like me who are getting help through this repo.
code :
bool isPallindrome(string &X, int i, int j) {
while (i <= j) {
if (X[i] != X[j])
return false;
i++, j--;
}
return true;
}
int Solve(string &X, int i, int j) {
if (i >= j || isPallindrome(X, i, j)) {
t[i][j] = 0;
return 0;
}
if (t[i][j] != -1)
return t[i][j];
int ans = INT_MAX;
for (int k = i; k < j; k++) {
int temp_ans = Solve(X, i, k) + Solve(X, k + 1, j) + 1;
ans = min(ans, temp_ans);
}
return t[i][j] = ans;
}
The text was updated successfully, but these errors were encountered:
Hey, this repo you have made has helped me a lot, because I get the logic but when it comes to coding it, it sometimes feels difficult, so thank you for making this amazing repo 🙌🙌.
In this -> https://github.com/shubhamchemate003/Dynamic-Programming-Questions-by-Aditya-Verma/blob/main/pallindrome_partitioning_memoization.cpp
and in this too -> https://github.com/shubhamchemate003/Dynamic-Programming-Questions-by-Aditya-Verma/blob/main/pallindrome_partitioning_memoized_optimization.cpp
just pass the string with reference(&) in both the function ( isPallindrome and Solve) and it will not give TLE .
Just wanted to help, because I think there would be a lot of people like me who are getting help through this repo.
code :
The text was updated successfully, but these errors were encountered: