프로그래머스

· Algorithms
-주사위의 개수 상자의 가로, 세로, 높이가 저장되어있는 배열 box와 주사위 모서리의 길이 정수 n이 매개변수로 주어졌을 때, 상자에 들어갈 수 있는 주사위의 최대 개수를 return class Solution { public int solution(int[] box, int n) { int answer = 0; answer = (box[0]/n) * (box[1]/n) * (box[2]/n); return answer; } } -합성수 찾기 class Solution { public int solution(int n) { int answer = 0; for (int i=3; i (int) IntStream.rangeClosed(1, i).filter(i2 -> i % i2 == 0).count() >..
· Algorithms
- 개미 군단 장군개미는 5의 공격력을, 병정개미는 3의 공격력을 일개미는 1의 공격력을 가지고 있습니다. 사냥감의 체력 hp가 매개변수로 주어질 때, 체력에 딱 맞게 최소한의 병력을 구성하려면 몇 마리의 개미가 필요한지를 return class Solution { public int solution(int hp) { int answer = 0; answer = hp / 5 + hp % 5 / 3 + hp % 5 % 3; return answer; } } - 모스 부호 import java.util.*; class Solution { public String solution(String letter) { String answer = ""; String[] morse = { ".-","-...","-.-...
· Algorithms
- 특정 문자 제거하기 class Solution { public String solution(String my_string, String letter) { my_string = my_string.replace(letter, ""); return my_string; } } 원래는 delete 메소드를 사용하려 했는데 delete(int start, int end) deleteCharAt(int index) 이렇게 위치도 알아야 하고, StringBuilder 쓰는 것이 불가피하여 다른 메소드를 찾아보던 중 replace를 발견! - 각도기 예각, 직각, 둔각, 평각 나타내기 class Solution { public int solution(int angle) { int answer = 0; double ..
유영서
'프로그래머스' 태그의 글 목록