diff --git a/week05-dp/leGit-y/.gitkeep b/week05-dp/leGit-y/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/week05-dp/leGit-y/1912.py b/week05-dp/leGit-y/1912.py new file mode 100644 index 0000000..a0855c4 --- /dev/null +++ b/week05-dp/leGit-y/1912.py @@ -0,0 +1,12 @@ +import sys +input = sys.stdin.readline +n = int(input()) +arr = list(map(int, input().split())) + + +for i in range(1, n): + arr[i] = max(arr[i], arr[i] + arr[i-1]) + +print(max(arr)) + + diff --git a/week05-dp/leGit-y/9251.py b/week05-dp/leGit-y/9251.py new file mode 100644 index 0000000..8585f5f --- /dev/null +++ b/week05-dp/leGit-y/9251.py @@ -0,0 +1,18 @@ +A = input() +B = input() + +N1 = len(A) +N2 = len(B) + +result = [[0] * (N2+1) for _ in range(N1+1)] + +for i in range(1, N1+1): + for j in range(1, N2+1): + + if A[i-1] == B[j-1]: + result[i][j] = result[i-1][j-1] + 1 + + else: + result[i][j] = max(result[i-1][j], result[i][j-1]) + +print(result[N1][N2])