Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-10-02] wooyeol #297#315

Merged
Woo-Yeol merged 1 commit into
mainfrom
wooyeol-#297
Oct 11, 2023
Merged

[2023-10-02] wooyeol #297#315
Woo-Yeol merged 1 commit into
mainfrom
wooyeol-#297

Conversation

@Woo-Yeol
Copy link
Copy Markdown
Member

@Woo-Yeol Woo-Yeol commented Oct 6, 2023

PR Summary

스킬트리
https://school.programmers.co.kr/learn/courses/30/lessons/49993

풀이시간
10:23 ~ 10:39 (16분)

문제 조건
1 <= len(skill) <= 26
1 <= len(skill_trees) <= 20
2 <= 각 skill_trees의 길이 <= 26

시간 복잡도 :
O(20 * 26)

접근법
무슨 알고리즘으로 풀이 할 수 있을까? -> 완전 탐색

데이터의 중복과 갯수가 크게 문제 되지 않기 때문에 완전 탐색으로 단순 구현을 진행하였습니다.

완전 탐색 과정
각각의 스킬트리 과정을 확인합니다.

  • 선행 스킬의 인덱스를 증가시키며 선행 스킬이 순서대로 주어지는지 확인하기
    • 스킬트리의 스킬을 하나씩 확인하고 선행 스킬에 포함된다면 등장해야하는 선행 스킬과 비교
      • 정상일 경우 다음 선행 스킬의 인덱스로 증가
      • 아니라면 인터럽트
    • 인터럽트가 일어나지 않은 스킬트리는 정답으로 인정

@Woo-Yeol Woo-Yeol requested a review from limstonestone October 6, 2023 13:49
@Woo-Yeol Woo-Yeol self-assigned this Oct 6, 2023
@Woo-Yeol Woo-Yeol linked an issue Oct 6, 2023 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@zsmalla zsmalla left a comment

Choose a reason for hiding this comment

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

어떤 라인이 핵심인지 바로 알 수 있어서 이해하기 쉬웠던 풀이인 것 같습니다! 탐색 연산 최적화를 위해 set으로 변환한 디테일까지 좋았던 것 같아요. 고생 많으셨습니다!

Comment thread Programmers/스킬트리/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이 포인터가 가르키는 스킬이 결국에는 다른 선행스킬보다 먼저 나와야 한다가 핵심인 풀이네요!

Comment thread Programmers/스킬트리/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

구현 로직 자체가 직관적이어서 빠르게 이해할 수 있었어요! 고생하셨습니다 우열님 👍👍👍

@Woo-Yeol Woo-Yeol merged commit 39b9dfe into main Oct 11, 2023
@Woo-Yeol Woo-Yeol deleted the wooyeol-#297 branch October 11, 2023 15:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Programmers] 스킬트리

3 participants