cpp_tour
cpp_tour copied to clipboard
LPSS Driver Index may be off by 1
In the driver program for dynamic_programming/LPSS, there may be an index issue where we should call p.LPSS(0, in.size()); with size-1. The bug isn't detected for LPSS because it returns the correct answer, but is seen when calling LPSS_memo because memo at that index isn't set with constructor, it will always return 0.
int main() { std::string in = "bbbab"; LPSS_Problem p(in); auto result = p.LPSS(0, in.size()); Print2dVector(p._memo); std::cout << "result: " << result << std::endl; return 0; }