Skip to content

Conversation

@dev-hjJoo
Copy link
Owner

To-do

  • 코드 리뷰를 위한 파이썬 코드 파일(code.py) 작성
  • 알고리즘에 대한 설명 및 히스토리 작성을 위한 문서 파일(description.py) 작성

Introduction

  • 시간 복잡도: O(N)
  • 주요 로직: 각 단계에서 첫 번째 스텝일 때와 두 번째 스텝일 때를 나누어 최대값을 업데이트 해 주었습니다. 특히 이전 스텝의 값을 활용하여 재연산을 방지하였습니다.

고민 방향

  • DP는 다양한 풀이가 있다고 알고 있어, 다른 방향의 풀이가 있다면 공유해주시면 감사하겠습니다.
  • 코드가 길지 않아서 자유롭게 피드백 주시면 감사하겠습니다!

@dev-hjJoo dev-hjJoo added the enhancement New feature or request label May 1, 2025
@dev-hjJoo dev-hjJoo requested a review from LeeSongMi May 1, 2025 12:20
@dev-hjJoo dev-hjJoo self-assigned this May 1, 2025
@dev-hjJoo dev-hjJoo moved this to In Progress in Algorithm Warm-Up May 2, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

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

현재 스텝이 두 번째 스텝일때의 최대값을 구하는거여서
max_scores[c_step-1][0]로 한 칸 이전 스텝의 최대값을 가져오는것까지는 이해했는데
c_step >= 1 else 0을 해주는 부분이 잘 이해가 안돼서요 😢
혹시 저부분은 어떤 의미를 나타내는건가용?

Copy link
Owner Author

Choose a reason for hiding this comment

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

s_score = max_scores[c_step-1][0]+c_score if c_step >= 1 else 0

안녕하세요 :)
위 구문은 3항 연산자입니다. 따라서 아래 코드와 동일한 역할을 하고 있습니다.

현재 스텝(c_step)이 두 번째 이후일 때부터 고려해주기 위해 c_step 값이 1 이상 (인덱스는 0부터 시작하기 때문)일 때부터 고려합니다.

if c_step >= 1:
    s_score = max_scores[c_step-1][0]+c_score
else:
    s_score = 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants