Skip to content

4월12일#9

Open
jhyii wants to merge 1 commit intomainfrom
투포인터

Hidden character warning

The head ref may contain hidden characters: "\ud22c\ud3ec\uc778\ud130"
Open

4월12일#9
jhyii wants to merge 1 commit intomainfrom
투포인터

Conversation

@jhyii
Copy link
Copy Markdown
Collaborator

@jhyii jhyii commented Apr 29, 2022

내용 & 질문
2473번이 자꾸 시간초과가 뜹니다! 해결방법이 궁금합니다..!
<기존 제출>
1253, 2531, 2473
<추가 제출>
X

Copy link
Copy Markdown

@nanometre380 nanometre380 left a comment

Choose a reason for hiding this comment

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

안녕하세요! 세문제 확인되었습니다. 하지만 2531번 문제는 조금 다른 풀이를 고민해보시면 좋을 것 같아요! 막히시는 경우 샘플 코드도 확인해주세요! 수고하셨습니다~

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

자기 자신을 피하기 위해서 copy로 복사해서 자기자신이 없는 배열을 만들어 주셨는데, copy는 시간복잡도가 o(n)이라서 배열이 길거나, 이렇게 반복문 안에 넣어 사용하는 경우 시간 복잡도 측면에서 좋지 않아요 ㅠㅠ!! 다른 방법을 고민해보셨으면 좋겠습니다!

Copy link
Copy Markdown

@nanometre380 nanometre380 May 2, 2022

Choose a reason for hiding this comment

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

여기서도 앞서 말씀드렸다시피 copy() 사용은 지양해주세요! (아마 시간 초과가 나면 이 부분 때문일 수도 있을 것 같아요!)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3. return을 하면 해당 함수가 값을 반환하며 종료되기 때문에 이후에 break문을 사용하실 필요가 없습니다!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

편리하게 이전에 배웠던 deque를 생각하신 것 같아요! deque를 사용하지 않고 투 포인터로 풀이할 수 있는 방법도 함께 고민해보셨으면 좋겠습니다~! 회전 때문에 사용하신 코드인지 arr = arr + arr[:k-1]를 사용하셨는데 시간복잡도 측면에서 좋지 못하니 여기도 다른 방법을 생각해보시면 더 좋을 것 같습니다. 원 형태에서는 모듈러 연산도 사용할 수 있을 것 같아요~

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

Successfully merging this pull request may close these issues.

2 participants