-
-
Notifications
You must be signed in to change notification settings - Fork 195
[sejineer] Week 06 solutions #1415
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
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.
6주차 고생하셨습니다!
if ch in node: | ||
return dfs(node[ch], idx + 1) | ||
elif ch == ".": | ||
return any(dfs(node[k], idx + 1) for k in node if k != "$") |
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.
any() 로 pythonic 하게 처리한 점 좋아요!
result.append(matrix[ny][nx]) | ||
x, y = nx, ny | ||
|
||
return result |
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.
vis 배열 없는 풀이도 참고하시면 좋을 것 같아요!
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
if not matrix or not matrix[0]:
return []
result = []
top, bottom = 0, len(matrix) - 1
left, right = 0, len(matrix[0]) - 1
while left <= right and top <= bottom:
result += matrix[top][left:right + 1]
top += 1
result += [matrix[i][right] for i in range(top, bottom + 1)]
right -= 1
if top <= bottom:
result += matrix[bottom][right:left - 1:-1] if right >= left else []
bottom -= 1
if left <= right:
result += [matrix[i][left] for i in range(bottom, top - 1, -1)]
left += 1
return result
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.
감사합니다! 도움 많이 됐습니다 ㅎㅎ
피드백 감사합니다. 다음 주차도 화이팅입니다! |
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!