public int solution(String s) {
int answer = 0;
char temp = s.charAt(0);
int startIndex = (temp == '-' || temp == '+') ? 1 : 0;
for (int i = startIndex; i < s.length(); i++) {
char ch = s.charAt(i);
int digit = ch - '0';
answer = answer * 10 + digit;
}
if (temp == '-')
answer *= -1;
return answer;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/12925
public double solution(int[] arr) {
int length = arr.length;
int sum = 0;
for (int i : arr) {
sum += i;
}
return (double) sum / length;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/12944