Skip to content

Conversation

@KimGyeongLock
Copy link

No description provided.

Copy link
Member

@yohanii yohanii left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다! 👍

  • 작은 함수 단위 분리
  • if else문 줄이기 + 중간 탈출
  • 네이밍
    부분 신경 써주시면, 가독성이 더 좋아질 거 같아요!

Comment on lines 11 to 19
if(pobi.size() != 2 || crong.size() != 2) {
return -1;
}
if(pobi.get(0) <= 1 || crong.get(0) <= 1 || pobi.get(1) >= 400 || crong.get(1) >= 400) {
return -1;
}
if(pobi.get(1) <= pobi.get(0) || pobi.get(1) - pobi.get(0) != 1 || crong.get(1) <= crong.get(0) || crong.get(1) - crong.get(0) != 1) {
return -1;
}
Copy link
Member

Choose a reason for hiding this comment

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

검증과정을 따로 함수로 빼서, 모아서 보면 더 좋을 것 같아요!

Comment on lines 23 to 27
if(pobiSum > crongSum) answer = 1;
else if(pobiSum < crongSum) answer = 2;
else answer = 0;

return answer;
Copy link
Member

Choose a reason for hiding this comment

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

answer에 값을 넣어서 마지막에 리턴하는 것보다,
중간에 탈출할 수 있게하면 더 좋을 것 같습니다!

그리고 마지막 else는 제거할 수 있을 거 같아요

return sum;
}

public static Integer plusMultiplyComp(Integer LR) {
Copy link
Member

Choose a reason for hiding this comment

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

Comp가 무엇을 뜻하는지 잘 모르겠어서, 풀어서 쓰는 것도 좋을 것 같아요
LR보다 더 이해하기 좋은 네이밍이 있을 것 같아요! 저는 page라고 했어요

}

public static Integer multiplyAll(List<Integer> allDigit) {
int sum = 1;
Copy link
Member

Choose a reason for hiding this comment

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

sum보다 더 좋은 네이밍이 있을 거 같습니다

for (int i = 0; i < cryptogram.length() - 1; i++) {
if (cryptogram.charAt(i) == cryptogram.charAt(i + 1)) {
cryptogram = cryptogram.substring(0, i) + cryptogram.substring(i + 2);
i--;
Copy link
Member

Choose a reason for hiding this comment

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

개인적으로 i를 바꾸는 것은 위험하다고 생각합니다!
i를 바꿔야한다면, for문 대신 while문이 더 괜찮을 거 같아요


public class Problem7 {

static HashMap<String, Integer> map = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

map 대신 더 좋은 네이밍이 있을 거 같아요

List<String> userFriend = friendPoint(user, friends);
visitorPoint(visitors, userFriend);

List<Map.Entry<String, Integer>> entries = new ArrayList<>(map.entrySet());
Copy link
Member

Choose a reason for hiding this comment

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

sort 과정을 함수로 뺄 수 있을 거 같아요

int valueComp = entry2.getValue().compareTo(entry1.getValue());
if(valueComp == 0) {
return entry1.getKey().compareTo(entry2.getKey());
} else {
Copy link
Member

Choose a reason for hiding this comment

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

else 문을 제거할 수 있을 거 같아요

return answer;
}

public static List<String> friendPoint(String user, List<List<String>> friends) {
Copy link
Member

Choose a reason for hiding this comment

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

작은 함수 단위로 분리하는게 보기 더 좋을 거 같아요

}

public static void visitorPoint(List<String> visitors, List<String> userFriend) {
for(int i = 0; i < visitors.size(); i++) {
Copy link
Member

Choose a reason for hiding this comment

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

index로 조회하는 것 보다 더 가독성 좋은 방법이 있습니다!

Suggested change
for(int i = 0; i < visitors.size(); i++) {
for(String visitor: visitors) {

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