Skip to content

26번 원형 데크 디자인 문제 깃허브 코드 오타 #160

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

Closed
Yanghyeondong opened this issue Nov 23, 2022 · 0 comments
Closed

26번 원형 데크 디자인 문제 깃허브 코드 오타 #160

Yanghyeondong opened this issue Nov 23, 2022 · 0 comments

Comments

@Yanghyeondong
Copy link
Contributor

안녕하세요 박상길 작가님! 26번 문제를 풀고 깃허브 코드를 보다가 간단한 오타가 보여 글을 올립니다.

문제 파일 링크

# Definition for singly-linked list.
class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None


class MyCircularDeque:
    def __init__(self, k: int):
        self.head, self.tail = ListNode(None), ListNode(None)
        self.k, self.len = k, 0
        self.head.right, self.tail.left = self.tail, self.head

해당 문제에서 이중 연결 리스트를 사용하셨는데, 정작 클래스 정의에는 단일 방향 리스트가 사용되었습니다.
하지만 신기하게도 다음 두 경우 덕분에 리트코드에서 통과는 문제가 없습니다.

  1. 저 부분이 없을 경우 리트코드에 기본 정의된 ListNode 때문에 정상 작동이 됩니다.
  2. 저 부분이 있더라도, 파이썬의 경우 각 인스턴스 변수를 외부에서 정의할 수 있으므로 이 또한 문제 없었습니다.
    ex.) self.head.right, self.tail.left = self.tail, self.head

다만, 수정하는 편이 조금이나마 헤매는 사람을 없앨 수 있을 것 같아서 글을 남깁니다.
좋은 책 감사합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants