Skip to content

Commit

Permalink
Merge pull request #25 from HYU-PS-STUDY/leGit-y
Browse files Browse the repository at this point in the history
[week-05-dp] 1912, 9251
  • Loading branch information
clean2001 authored Feb 22, 2024
2 parents 0ba18c6 + 29d89f5 commit a5ea038
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Empty file removed week05-dp/leGit-y/.gitkeep
Empty file.
12 changes: 12 additions & 0 deletions week05-dp/leGit-y/1912.py
Original file line number Diff line number Diff line change
@@ -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))


18 changes: 18 additions & 0 deletions week05-dp/leGit-y/9251.py
Original file line number Diff line number Diff line change
@@ -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])

0 comments on commit a5ea038

Please sign in to comment.