YoonYn9915/1월 3주차 /3문제 #126
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🌱WIL
🚀주간 목표 문제 수: 3개
백준 #5582. 공통부분문자열: DP / 골드5
정리한 링크: (바로가기)
🚩제출한 코드
백준 #20542. 받아 쓰기: DP, 문자열 / 골드 3
정리한 링크: (바로가기)
🚩플로우 (선택)
입력 처리
N, M 입력: 각각 문자열 inp와 answer의 길이를 나타냅니다.
두 문자열 inp와 answer 입력:
DP 테이블 초기화
크기가 (N+1) x (M+1)인 2차원 DP 테이블 생성:
DP 테이블 값 채우기
i == 0: inp가 빈 문자열인 경우, answer의 첫 j개 문자를 만들기 위해 삽입 연산만 필요합니다.
j == 0: answer가 빈 문자열인 경우, inp의 첫 i개 문자를 삭제 연산으로 비워야 합니다.
inp[i-1]와 answer[j-1]를 비교:
문자가 같은 경우: 대각선(dp[i-1][j-1]) 값을 그대로 가져옵니다.
inp[i-1] == 'i'일 때 answer[j-1]가 'l' 또는 'j'라면 대각선 값을 그대로 사용합니다.
inp[i-1] == 'v'일 때 answer[j-1]가 'w'라면 대각선 값을 그대로 사용합니다.
일반적인 다른 경우: 삽입, 삭제, 교체 중 최소 연산을 선택한 후 +1을 더합니다.
최종 결과 출력
DP 테이블의 최우하단 값 dp[N][M]이 inp와 answer 간의 최소 편집 거리를 나타냅니다.
🚩제출한 코드
백준 #1522. 문자열 교환: 구현, 문자열 / 실버 1
정리한 링크: (바로가기)
🚩제출한 코드