Skip to content

Conversation

@platycodonv
Copy link
Collaborator

0401프로그래머스 문제 1번,2번

0401프로그래머스 문제 1번,2번
@ghost ghost requested review from a user, Kuuuna98, taboowiths and tgb02087 March 31, 2022 17:52
@ghost ghost assigned platycodonv Mar 31, 2022
@ghost ghost added the in progress 진행중입니다. label Mar 31, 2022
if(number == 0) return false;
if(number == 1) return false;
if(number == 2) return true;
for(int i = 3; i<=Math.sqrt(number); i = i+2) {
Copy link

Choose a reason for hiding this comment

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

매우 좋은 코드였습니다. 감사합니다 !


String sector = "";
for(int i = 0; i<change.length();i++) {
if(change.charAt(i) != '0') sector += change.charAt(i);
Copy link

Choose a reason for hiding this comment

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

String에 + 연산이 많아질거 같은 경우에는 StringBuilder를 사용하는 것을 권장합니다 !
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

좋아용~

if(number == 0) return false;
if(number == 1) return false;
if(number == 2) return true;
for(int i = 3; i<=Math.sqrt(number); i = i+2) {
Copy link
Member

Choose a reason for hiding this comment

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

for문이 반복할 때마다 조건문을 확인하기 때문에, 매번 Math.sqrt() 함수가 실행됩니다
변수로 저장해서 사용하면 sqrt함수 실행을 한번만 하기 때문에 시간적으로 더 좋은 코드가 될 수 있을 거라 생각합니다~~!😺

@Kuuuna98 Kuuuna98 added the una confirm 확인~! :P label Mar 31, 2022
@ghost ghost added the invitejay confirm 권용재 검출기에 통과했습니다 label Apr 1, 2022
@tgb02087 tgb02087 added the zlzonKH zi존강호 label Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in progress 진행중입니다. invitejay confirm 권용재 검출기에 통과했습니다 una confirm 확인~! :P zlzonKH zi존강호

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants