Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[week-05-dp] 25215, 2533 #22

Merged
merged 1 commit into from
Feb 22, 2024
Merged

[week-05-dp] 25215, 2533 #22

merged 1 commit into from
Feb 22, 2024

Conversation

clean2001
Copy link
Contributor

@clean2001 clean2001 commented Feb 19, 2024


for(int i=1; i<s.length(); ++i) {
if(s.charAt(i) >= 'a' && s.charAt(i) <= 'z') { // 소문자이면
dp[0][i] = Math.min(dp[0][i-1] + 1, dp[1][i-1]+2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오.. 각 문자열 인덱스마다 마름모 켜져있다/안켜져있다로 해서 2차원 dp를 돌리는군요
1149. RGB 거리 문제랑 거의 비슷하게 풀 수 있었네요 😊

System.out.println(Math.min(dp[0][1], dp[1][1]));
}

static void dfs(int cur, int prev) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파라미터로 prev 를 전달하니까 외부에 방문했음을 나타내는 배열을 관리안해줘도 되는군요!
하나 알아갑니다 ;)

Copy link
Contributor

@wonkyDD wonkyDD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@clean2001 clean2001 merged commit 1374266 into main Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[week-05-dp] 25215, 2533
2 participants