class Solution { public int solution(String num_str) { int answer = 0; for(int i = 0; i < num_str.length(); i++) { answer += Integer.parseInt(num_str.substring(i, i+1)); } return answer; } }
class Solution { public int solution(int[] arr1, int[] arr2) { int answer = 0; if(arr1.length != arr2.length) { answer = (arr1.length > arr2.length) ? 1 : -1; } else { int num1 = 0; int num2 = 0; for(int i = 0; i num2) ? 1 : (num1 < num2) ? -1 : 0; } } return answer; } }
class Solution { public String solution(String my_string, int[] index_list) { String answer = ""; for(int i = 0; i < index_list.length; i++) { answer += my_string.substring(index_list[i], index_list[i]+1); } return answer; } }
class Solution { public String solution(String cipher, int code) { String answer = ""; for(int i = 0; i < cipher.length(); i++) { if((i + 1) % code == 0) { answer += cipher.substring(i, i + 1); } } return answer; } }
class Solution { public int solution(int hp) { int answer = 0; // 5, 3, 1 while (true) { if(hp >= 5) { answer += hp / 5; hp = hp % 5; } else if (hp >= 3) { answer += hp / 3; hp = hp % 3; } else if (hp >= 1) { answer += hp / 1; hp = hp % 1; } else if ( hp