-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확실히 재귀로 풀어내니 직관적이네요!!
감사합니다 수민님!
|
||
def solution(word: str) -> int: | ||
go(0, '') | ||
for i, w in enumerate(dic, start=1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
start=1 이라는 옵션은 처음 보네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
222222 이러면 인덱스가 1부터 시작하군요..
(근데 22222 이거 쓰면 요새 틀딱이래요)
- 알파벳 대문자 'A', 'E', 'I', 'O', 'U'로만 이루어져 있음 | ||
|
||
<solution> | ||
만들 수 있는 모든 단어를 만들어도 5**5 = 3125밖에 되지 않기 때문에, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굳이 따지자면(?) 모든 단어의 길이가 5가 아니기 때문에 경우의수가 더 늘어나긴 합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
옹 5!이 맞는 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
깔끔하고 효율적인 DFS 풀이였습니다! DFS 함수에서 조금 더 최적화할 수 있는 방안에 대해서 코멘트 달아두었으니 참고해주시면 좋을 것 같아요. 아픈데도 수고 많으셨습니다 수민님!
- 알파벳 대문자 'A', 'E', 'I', 'O', 'U'로만 이루어져 있음 | ||
|
||
<solution> | ||
만들 수 있는 모든 단어를 만들어도 5**5 = 3125밖에 되지 않기 때문에, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
옹 5!이 맞는 것 같아요!
|
||
mo = "AEIOU" | ||
dic = [] | ||
def go(index: int, alpha: str) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go 함수 내부에서 len(alpha)를 계산한다면 index 매개변수는 안써도 되어 조금 더 좋을 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
재귀 짤때마다 index넘겨주는게 습관이 돼서 다음번 부터는 len을 써보겠습니다..!! 감사합니다 지수님:)
|
||
def solution(word: str) -> int: | ||
go(0, '') | ||
for i, w in enumerate(dic, start=1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
222222 이러면 인덱스가 1부터 시작하군요..
(근데 22222 이거 쓰면 요새 틀딱이래요)
|
||
mo = "AEIOU" | ||
dic = [] | ||
def go(index: int, alpha: str) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
와 재귀를 생각하신건 정말 대단하신 것 같아요 재귀의 특성을 정확히 이해하고 계신 것에 감탄이 나옵니다.
PR Summary
풀이시간: 10분
<input>
word: 단어 하나
<solution>
만들 수 있는 모든 단어를 만들어도 5**5 = 3125밖에 되지 않기 때문에,
모든 단어를 브루트포스로 만들어 해당 단어가 몇 번째 단어인지 확인한다.
<시간복잡도>
O(5 ** 5) = O(3125) -> O(1): 상수시간
사전을 만드는데 가장 오랜 시간이 걸린다.