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

[투포인터] 11월 14일 #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[투포인터] 11월 14일 #9

wants to merge 1 commit into from

Conversation

mengzii
Copy link
Collaborator

@mengzii mengzii commented Nov 14, 2023

인적사항

학번: 1985086
이름: 임은지

과제제출

기존제출: 2531, 14503, 20922
추가제출:

Copy link

@mingulmangul mingulmangul left a comment

Choose a reason for hiding this comment

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

[투포인터 알고리즘 코드 리뷰 완료]
20922(P3), 2531(P3)
안녕하세요 은지님!
모든 문제가 로직도 구현도 정말 깔끔하고 잘 풀어주신 것 같습니다👍
아주 사소한 코멘트만 몇 개 남겼는데 한 번 읽어봐주세요~
과제하느라 고생많으셨습니다🥰💚

cin >> belt[i];
}

result = maxSushi(n, d, k, c, belt);

Choose a reason for hiding this comment

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

연산부를 별도 함수로 분리해주셨네요! 덕분에 코드가 정말 깔끔해보이는 것 같아 좋습니다 👍👍👍

Comment on lines +20 to +29
count[belt[i]] -= 1;
if(count[belt[i]] == 0){
plate -= 1;
}

int temp = (i+k) % n;
count[belt[temp]] += 1;
if(count[belt[temp]] == 1){
plate += 1;
}

Choose a reason for hiding this comment

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

포인터 계산이나 두 포인터를 이용해서 plate를 계산하는 로직 모두 잘 구현해 주신 것 같습니다!🤗🤗

Comment on lines +31 to +36
if(count[c] == 0){
max_plate = max(max_plate, plate + 1);
}
else{
max_plate = max(max_plate, plate);
}

Choose a reason for hiding this comment

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

P3. 쿠폰으로 먹은 초밥을 미리 초기화해두면 어떨까요? 그러면 if문을 생략할 수 있어 보입니다 :)

Comment on lines +16 to +19
while(count[list[right]] > k){
count[list[left]] -= 1;
left++;
}

Choose a reason for hiding this comment

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

left 포인터를 이동해야 하는 조건을 잘 캐치하고 구현해주신 것 같습니다 👍 👍

#include <vector>

using namespace std;
const int max_num = 100001;

Choose a reason for hiding this comment

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

P3. 숫자 리터럴을 상수로 선언해 사용하신 것 정말 좋습니다!! 상수는 보통 네이밍할 때 대문자를 사용하니까 대문자로 작성해주시면 더 좋을 것 같아요

Copy link

@kimhj010502 kimhj010502 left a comment

Choose a reason for hiding this comment

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

[투 포인터 구현 문제 코드 리뷰 완료]

14503(P3)

은지님 안녕하세요!
과제하시느라 수고 많으셨습니다!! 어려운 문제인데도 잘 풀어주셨네요! 🥰
코드에 대한 간단한 주석이 있으면 더 좋을 것 같아요. 😎
몇 가지 사소한 코멘트 드렸습니다.
궁금한 점이 있으면 리뷰어를 호출해주세요!

Comment on lines +5 to +6
const int max_n = 50;
const int max_m = 50;

Choose a reason for hiding this comment

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

상수는 대문자로 작성해주세요~! 그리고 max_n과 max_m이 같은 값을 가지고 있는 이 경우에는 const int MAX = 50;으로 한 번만 선언해줘도 될 것 같네요!

Comment on lines +21 to +22
if (room[robotr - 1][robotc] != 0 && room[robotr][robotc + 1] != 0 &&
room[robotr + 1][robotc] != 0 && room[robotr][robotc - 1] != 0) {

Choose a reason for hiding this comment

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

주변 4개의 방향 탐색을 하나의 조건문으로 한 번에 진행해주었군요! 이 방법도 좋지만 미리 상수로 선언해 놓은 방향 배열을 사용해서 더 가독성 좋은 코드를 작성할 수 있을 것 같아요!

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.

3 participants