Skip to content
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

[투 포인터] 4월 28일 #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[투 포인터] 4월 28일 #12

wants to merge 2 commits into from

Conversation

soletree
Copy link
Collaborator

내용 & 질문

제출합니다!

<기존 제출>

1253, 1484, 2473, 2531

<추가 제출>

@soletree soletree closed this Apr 27, 2022
@soletree soletree reopened this Apr 27, 2022
Copy link

@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.

안녕하세요! 문제들은 이제 정말 잘 푸시는 것 같아요 👍 👍 다만 투포인터 과제인만큼 투포인터를 사용한 풀이를 고민해봐주셨으면 좋겠습니다! 제출 인정은 드리나, 1484번과 2531번은 다시 한 번 풀어봐주시길 바랍니다~! 특히 2531번은 in 연산자를 쓰셨는데, 시간복잡도 O(n)으로 시간복잡도 면에서 유리하지 않습니다 ㅠㅠ! 고민해보시고, 샘플코드도 참고해주세요~ 이번 과제도 너무 수고하셨습니다~!!!!

while left<right:
#자기 자신은 좋은 수에서 제외
if left==idx: left+=1; continue
elif right==idx: right-=1; continue

Choose a reason for hiding this comment

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

투포인터 잘 사용해주셨고, 자기 자신과 같을 때를 피해주시는 것도 너무 좋아요! 다만 이렇게 짧은 경우에는 행을 결합해도 큰 영향이 없지만 행의 길이가 길어질 땐 행 분리를 해주시는 게 좋아요!

present=(past**2+g)**0.5
if present.is_integer():
ans.append(int(present))
return ans

Choose a reason for hiding this comment

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

구하고자 하는 것이 현재 몸무게이기 때문에 present = (past**2 + g) **0.5 처럼 past값을 이용하여 present를 구하고자 하신 것 같은데, 투포인트에서는 다른 풀이가 가능합니다. 자연수 범위 내에서 past와 present를 이동시켜가며 g를 구할 수 있지 않을까요?

if mix<0:left+=1
else:right-=1

return ans

Choose a reason for hiding this comment

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

풀이 너무 너무 좋아요! 사소한 이야기지만, 코드 작성 시 줄 바꿀 때 가독성을 조금만 고려해주시면 정말 완벽할 거 같아요! 연관된 코드 덩어리끼리 뭉쳐있는 게 훨씬 깔끔해 보이거든요 ㅎㅎ!

#최대 가짓수 저장
elif max_kind<len_c:
max_kind=len_c
max_check=check

Choose a reason for hiding this comment

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

회전 초밥 벨트이기 때문에 deque를 생각하신 것 같아요! 이 풀이도 좋은 방법이지만 투 포인터 문제이기 때문에 투 포인터로 풀이할 수 있는 방법을 고민해보셨으면 좋겠습니다 ㅠㅠ~!

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