프로그래머스 5

프로그래머스 코딩테스트 입문 4

2022.11.26일 7문제 완료 기록. 개미 군단 class Solution { public int solution(int hp) { int answer = 0; int num=0; if(hp%5==0){ answer=hp/5; }else{ answer+=hp/5; hp=hp%5; if(hp>=3){ answer+=hp/3; hp=hp%3; if(hp>0){ answer+=hp; } }else{ answer+=hp; } } return answer; } } n의 배수 고르기 class Solution { public int[] solution(int n, int[] numlist) { int[] arry = new int[numlist.length]; int count = 0; for(int i = 0..

프로그래머스 코딩테스트 입문 3

2022.11.24일 9문제 완료 기록. 짝수는 싫어요 class Solution { public int[] solution(int n) { int k=0; int[] answer; if(n%2==0){ answer = new int [n/2]; }else{ answer = new int [n/2+1]; } for(int i=0;i= 100000) { price *= 0.95; } return price; } } 문자열안에 문자열 import java.util.*; class Solution { public int solution(String str1, String str2) { int answer = 0; if(str1.contains(str2)) { answer=1; }else { answer=2; ..

프로그래머스 코딩테스트 입문 2

2022.11.22일 12문제 완료 기록. 문제를 풀면서 느낀점은 내가 알지 못하는 Math함수들의 종류이다. 간단히 소수점 없애기 Math.floor 정도만 인지하고있었지 다양하게 존재한다는걸 다시한번 느끼고 공부의 필요성을 느끼게되었다. 점의 위치 구하기 class Solution { public int solution(int[] dot) { int answer = 0; if(dot[0]>0){ if(dot[1]>0){ answer=1; }else{ answer=4; } }else{ if(dot[1]>0){ answer=2; }else{ answer=3; } } return answer; } } 삼각형의 완성조건 (1) import java.util.*; class Solution { public i..

프로그래머스 코딩테스트 입문1

2022.11.21일 20문제 완료 기록. 정답이 높은 순서대로 푼 20문제라 딱히 어렵거나 힘든 문제는 없었다. 이클립스에서 코딩하는 것이 아닌 프로그래머스 안에서 코딩을 진행하다보니 필요한 것들을 import 해줘야한다는 사실을 알았다. 보통의 경우 import java.util.*; 소스를 통해서 가능하다! 두 수의 차 class Solution { public int solution(int num1, int num2) { int answer = num1-num2; return answer; } } 몫 구하기 class Solution { public int solution(int num1, int num2) { int answer = num1/num2; return answer; } } 숫자 비교..