public static int diagonalDifference(List<List<Integer>> arr) {
int count = arr.size();
int sum1 = 0;
int sum2 = 0;
for (int i = 0; i < arr.size(); i++) {
sum1 += arr.get(i).get(i);
}
for (int i = arr.size() - 1; i >= 0; i--) {
sum2 += arr.get(arr.size() - 1 - i).get(i);
}
return Math.abs(sum1 - sum2);
}
static int saveThePrisoner(int n, int m, int s) {
int candyLeft = m;
if ((n - (s - 1) > candyLeft)) {
return (s - 1) + candyLeft;
}
candyLeft = candyLeft - (n - (s - 1));
return (candyLeft % n == 0) ? n : candyLeft % n;
}
나머지 두 문제는 전에 풀었었고.. 나는 코드구현을 해야한다.. 구현 끝나고 시간이 남으면(과연) 남은 두 문제도 풀어봐야겠다.
어제는 일찍이 수면제를 먹고 자서 오늘 아침 일찍 일어났다. 잠들기 직전에도 일어나자마자도 기분이 너무 안 좋았는데 운동하고 샤워하고 아침까지 먹고 공부를 시작했더니 머리가 깨끗히 비워진 기분이었다. I never realized how you have to let the thoughts in your head and mind flow in order to get rid of them instead of trying not to think(it only makes you overthink).
간만에 알고리즘 풀었다. 재밌다. 쉬운 알고리즘 문제는 자존감부스터 역할을 해준다..