From 72e3f1ff61cc7aa9a3402628ab149a42b7b62b2a Mon Sep 17 00:00:00 2001 From: Rwithik Manoj Date: Sat, 31 Aug 2019 13:43:11 +0530 Subject: [PATCH] Fix possible error in longest_common_subsequence.py 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 7447a0cc7810..d39485408988 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: