From d4151bd5164d99a8184a4d842fe5e36305716dbc Mon Sep 17 00:00:00 2001 From: Rwithik Manoj Date: Sat, 31 Aug 2019 17:10:50 +0530 Subject: [PATCH] Fix possible error in longest_common_subsequence.py (#1163) The comparison at line 53 was not checking if (j > 0). --- dynamic_programming/longest_common_subsequence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dynamic_programming/longest_common_subsequence.py b/dynamic_programming/longest_common_subsequence.py index 7447a0cc7..d39485408 100644 --- a/dynamic_programming/longest_common_subsequence.py +++ b/dynamic_programming/longest_common_subsequence.py @@ -50,7 +50,7 @@ def longest_common_subsequence(x: str, y: str): seq = "" i, j = m, n - while i > 0 and i > 0: + while i > 0 and j > 0: if x[i - 1] == y[j - 1]: match = 1 else: