Learntosurf / 11월 5주차 / 7문제 #99
Merged
learntosurf merged 10 commits intoAlgorithmStudy-Allumbus:mainfrom Dec 2, 2024
Merged
Conversation
Mingguriguri
approved these changes
Dec 1, 2024
Collaborator
Mingguriguri
left a comment
There was a problem hiding this comment.
과제 문제는 못 풀었지만, 매일 꾸준히 문제를 푸셨던 점에서 멋지다고 느껴지네요!! 고생 많으셨습니다
Comment on lines
12
to
18
Collaborator
There was a problem hiding this comment.
1차원 배열로 어떻게 풀지, 싶었는데 훨씬 더 효율적인 풀이인 것 같네요!
2차원이 아닌 1차원으로 접근한 방식에 배워갑니다. :D
Collaborator
There was a problem hiding this comment.
중간에 잃어버린 괄호에 대한 코드가 없는 것 같네요! 확인해주세요!
추가로 앞으로 PR 올리실 때 Asignee랑 Reviewrs도 함께 등록해주시면 감사하겠습니다!
Member
There was a problem hiding this comment.
보통 이런 문제는 2차원 배열로 만들어 풀긴 하는데 1차원 리스트로도 푸셨네요. 메모리 제한이 있을때는 이런 방식으로 푸는게 더 좋을거 같네요 참고가 되었습니다!
YoonYn9915
approved these changes
Dec 1, 2024
Comment on lines
12
to
18
Member
There was a problem hiding this comment.
보통 이런 문제는 2차원 배열로 만들어 풀긴 하는데 1차원 리스트로도 푸셨네요. 메모리 제한이 있을때는 이런 방식으로 푸는게 더 좋을거 같네요 참고가 되었습니다!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
🚀주간 목표 문제 수: 5개
백준 #2748. 피보나치 수 2: DP / 브론즈1
정리한 링크: 바로가기
🚩플로우 (선택)
[0]*n+1로 초기화한다.dp[1]는 1로 초기화하여, 0,1로 시작할 수 있도록 한다.🚩제출한 코드
💡TIL
백준 #11724. 연결 요소의 개수: 그래프 순회 / 실버2
정리한 링크: 바로가기
🚩플로우 (선택)
🚩제출한 코드
💡TIL
adj[i][j]: 노드 i에서 j로 가는 간선이 존재할 경우 1, 아니면 0adj[i]: i번째 노드에 연결된 노드들을 원소로 갖는 리스트adj[i]리스트를 순회하며adj[i][j]가 1인지 0인지만 확인하면백준 #12865. 평범한 배낭: DP / 골드5
정리한 링크: 바로가기 (정리중)
🚩제출한 코드
💡TIL
백준 #1463. 1로 만들기: DP / 실버3
정리한 링크: 바로가기
🚩플로우 (선택)
dp[1] = 0이다. 연산을 진행할 필요가 없다.dp[N]의 결과를 출력한다.🚩제출한 코드
💡TIL
min(),max()연산을 사용하여 변화된 값과 비교하여 현재 값을 결정하게 하는 풀이들이 많다.백준 #2579. 계단 오르기: DP 실버3
정리한 링크: 바로가기
🚩플로우 (선택)
DP에 저장할 값은 DP[i]번째까지 왔을 때 점수의 최대값이다.
DP[0] = stair[0]DP[1] = stair[0] + stair[1]DP[2] = stair[1] + stair[2] or stair[0] + stair[2]DP[2] = stair[0] + stair[1] + stair[3] + stair[4] or stair[0] + stair[2] + stair[4]⇒
DP[i] = max(DP[i-3] + stair[i-1] + stair[i], DP[i-2] + stair[i])🚩제출한 코드
💡TIL
백준 #1541. 잃어버린 괄호: 그리디 / 실버2
정리한 링크: (바로가기)
🚩플로우 (선택)
🚩제출한 코드
💡TIL
“현재 상태로 이전 상태들로 표현할 수 있는가?”
"처음 몇 개의 경우는 예외적으로 처리해야 하는가?”
dp[i]의 의미를 명확히 정의한다. 문제에서 요구하는 최종 답을 dp의 어떤 값과 연결해야하는지를 고민한다."이 값이 무엇을 나타내는가?”
dp[i]를 이전 값(dp[i-1],dp[i-2],..)으로 표현할 방법을 찾는다."현재 상태를 바로 이전 상태들과 연결하는 법”
백준 #12026. BOJ 거리: DP / 실버1
정리한 링크: 바로가기
🚩플로우 (선택)
dp[1] = 0(출발점에서는 에너지가 필요하지 않음), 나머지dp[i] = inf로 설정한다.dp[i]: 1번 보도블록에서🚩제출한 코드
💡TIL
dp[i]초기화(INF)를 잊지 말고,dp[0]만 0으로 설정해야 한다.dp[i]는 ‘아직 도달할 수 없음’을 나타내야 한다. 이 상태를 무한대(INF)로 설정한다.dp[i]를 0으로 초기화하면, 아직 도달하지 않은 블록도 "에너지가 0"인 상태로 간주된다.dp[i]는INF대신 실제 최소 에너지 값으로 갱신된다.백준 1495. 기타리스트: DP / 실버1
정리한 링크: 바로가기
🚩플로우 (선택)
dp[i-1][j])에서P + V[i]와P - V[i]를 계산하고, 범위 내에 있다면dp[i][j]를 갱신한다.dp[N])을 뒤에서부터 탐색하여, 가능한 최대 볼륨 값을 찾는다. 찾지 못했다면 볼륨을 조절할 수 없다는 의미이므로 -1을 출력한다.🚩제출한 코드
💡TIL