240714

Regular KimΒ·2024λ…„ 7μ›” 14일
0

회고

λͺ©λ‘ 보기
50/71

240714 회고 πŸ’¬

이λ ₯μ„œλ₯Ό μš”μ¦˜ λ‹€μ‹œλ³΄κ³  μžˆλ‹€. μ΅œμ‹ ν™”λ₯Ό 해보렀고 ν–ˆμ§€λ§Œ μ·¨μ—… 후에 뭐 ν•΄λ†“μ€κ²Œ μ—†μ–΄μ„œ λ‚΄μš© μ±„μš°κΈ°κ°€ 생각보닀 만만치 μ•Šλ‹€. 날은 ν‘Ήν‘Ή μ°ŒλŠ”λ° 이λ ₯μ„œλŠ” μ“Έκ²Œ μ—†κ³ ,,, μ΄λž˜μ €λž˜ νž˜λ“  μ‹œκ°„μ΄λ‹€. μž₯λ§ˆκ°€ κΈ°λŒ€λ˜λŠ” 7μ›” λ‘˜μ§Έ μ£Όλ₯Ό λ˜λŒμ•„λ³Έλ‹€.

Keep πŸ‘

  • 이번 주에도 μ•Œκ³ λ¦¬μ¦˜ λ¬Έμ œν’€μ΄λ₯Ό 7일 연속 ν•΄λƒˆλ‹€. 이번 μ£Όμ—λŠ” 싀버 λ‚œμ΄λ„ 문제λ₯Ό ν’€μ—ˆλ‹€.
    - μ˜¬λ¦Όν”½ λ‚΄ 생각에 싀버 5 λ¬Έμ œλŠ” μ•„λ‹Œλ“― ν•˜λ‹€. 4λ‚˜ 3정도 λ‚œμ΄λ„μΈκ±° 같은데 싀버 5라고 μ‰½κ²Œ μƒκ°ν–ˆλ‹€κ°€ ν•œμ°Έ λΆ™μž‘κ³  μžˆμ—ˆλ‹€. Comparable κ΅¬ν˜„ ν›„ 인덱슀만 좜λ ₯ν•˜λ©΄ λ˜κ² λ‹€ μƒκ°ν–ˆλ‹€. 근데 곡동 μˆœμœ„ κ΅¬ν•˜λŠ” λ‘œμ§μ—μ„œ μ‹œκ°„μ΄ 많이 κ±Έλ Έλ‹€.
    - ν–‰λ ¬ κ³±μ…ˆ 고등학ꡐ 생각도 λ‚˜κ³  ν•΄μ„œ ν’€μ–΄λ΄€λ‹€. ν–‰λ ¬ κ³±ν•˜κΈ° 둜직 κ΅¬ν˜„μ΄ 생각보닀 쉽지 μ•Šλ‹€. 차원이 μž‘μ€ ν–‰λ ¬λ“€ μ—¬λŸ¬κ°œ κ³„μ‚°ν•΄κ°€λ©΄μ„œ ν’€μ΄ν–ˆλ‹€.
  • 이번 μ£Όμ—λŠ” 약속이 λ§Žμ•„ μŠ€ν”„λ§ 곡뢀에 μ‹œκ°„μ„ 많이 ν• μ• ν•˜μ§€ λͺ»ν–ˆλ‹€.
    - JPA κ°œλ… 볡슡
    - μŠ€ν”„λ§ 데이터 JPA ν•™μŠ΅
    - μŠ€ν”„λ§ κΈ°λ³Έ μ–΄λ…Έν…Œμ΄μ…˜ 볡슡
    - Validation
    - doFilter
    - Interceptor

Try 🧚

  • μŠ€ν”„λ§ μ˜ˆμ™Έμ²˜λ¦¬ ν•Έλ“€λŸ¬ κ°œλ… λ³΅μŠ΅ν•˜κΈ°
  • 이λ ₯μ„œ λ‚΄μš© λ³΄κ°•ν•˜κΈ°
  • ν”„λ‘œκ·Έλž˜λ¨Έμ˜ κΈΈ, λ©˜ν† μ—κ²Œ 묻닀 μ„œν‰ λ§ˆλ¬΄λ¦¬ν•˜κΈ°
  • ν•¨κ»˜ 자라기 λ§ˆλ¬΄λ¦¬ν•˜κΈ°

Extras πŸ˜€

ν–‰λ ¬ κ³±μ…ˆ


import java.io.*;

public class Main {

    public static void main(String[] args) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

            Solution s = new Solution();
            System.out.println(s.solution(getInput(br), getInput(br)));

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static int[][] getInput(BufferedReader br) throws IOException {
        String[] dimensions = br.readLine().split(" ");
        int rows = Integer.parseInt(dimensions[0]);
        int cols = Integer.parseInt(dimensions[1]);
        int[][] result = new int[rows][cols];
        for (int i = 0; i < rows; i++) {
            String[] line = br.readLine().split(" ");
            for (int j = 0; j < cols; j++) {
                result[i][j] = Integer.parseInt(line[j]);
            }
        }
        return result;
    }
}

class Solution {

    public String solution(int[][] matrix1, int[][] matrix2) {
        Calculator c = new Calculator(matrix1, matrix2);
        return c.getAnswer();
    }

    private class Calculator {

        int[][] matrix1;
        int[][] matrix2;
        int[][] result;

        public Calculator(int[][] matrix1, int[][] matrix2) {
            this.matrix1 = matrix1;
            this.matrix2 = matrix2;
            this.result = new int[matrix1.length][matrix2[0].length];
        }

        public String getAnswer() {
            for (int i = 0; i < result.length; i++) {
                for (int j = 0; j < result[i].length; j++) {
                    result[i][j] = calc(i, j);
                }
            }
            return getResult();
        }

        private int calc(int x, int y) {
            int[] xMatrix = matrix1[x];
            int[] yMatrix = getYMatrix(y);

            int result = 0;
            for (int i = 0; i < xMatrix.length; i++) {
                result += xMatrix[i] * yMatrix[i];
            }
            return result;
        }

        private int[] getYMatrix(int y) {
            int[] result = new int[matrix2.length];

            for (int i = 0; i < matrix2.length; i++) {
                result[i] = matrix2[i][y];
            }
            return result;
        }

        private String getResult() {
            StringBuilder answer = new StringBuilder();
            for (int i = 0; i < result.length; i++) {
                for (int j = 0; j < result[i].length; j++) {
                    answer.append(result[i][j]).append(" ");
                }
                answer.append("\n");
            }
            return answer.toString();
        }
    }
}

μ˜¬λ¦Όν”½


import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

            String[] tokens = br.readLine().split(" ");
            int len = Integer.parseInt(tokens[0]);
            int target = Integer.parseInt(tokens[1]);
            Solution s = new Solution();
            System.out.println(s.solution(getInput(br, len), target));

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static int[][] getInput(BufferedReader br, int len) throws IOException {
        int[][] result = new int[len][4];
        for (int i = 0; i < result.length; i++) {
            String[] line = br.readLine().split(" ");
            for (int j = 0; j < result[i].length; j++) {
                result[i][j] = Integer.parseInt(line[j]);
            }
        }
        return result;
    }
}

class Solution {

    public int solution(int[][] countries, int target) {
        Country[] order = new Country[countries.length];

        for (int i = 0; i < countries.length; i++) {
            int[] country = countries[i];
            int name = country[0];
            int gold = country[1];
            int silver = country[2];
            int bronze = country[3];
            order[i] = new Country(name, gold, silver, bronze);
        }
        Arrays.sort(order);
        order[0].rank = 1;

        rankCountry(order);

        return getOrder(target, order);
    }

    private void rankCountry(Country[] order) {
        for (int i = 1; i < order.length; i++) {
            if (isSameRank(order[i-1], order[i])) {
                order[i].rank = order[i-1].rank;
            } else {
                order[i].rank = i + 1;
            }
        }
    }

    private boolean isSameRank(Country prev, Country cur) {
        return cur.gold == prev.gold && cur.silver == prev.silver && cur.bronze == prev.bronze;
    }

    private int getOrder(int target, Country[] order) {
        for (Country country : order) {
            if (country.name == target) {
                return country.rank;
            }
        }
        return -1;
    }

    private class Country implements Comparable<Country> {

        int name;
        int gold;
        int silver;
        int bronze;
        int rank = 0;

        public Country(int name, int gold, int silver, int bronze) {
            this.name = name;
            this.gold = gold;
            this.silver = silver;
            this.bronze = bronze;
        }


        @Override
        public int compareTo(Country o) {
            if (this.gold == o.gold && this.silver == o.silver) {
                return o.bronze - this.bronze;
            } else if (this.gold == o.gold) {
                return o.silver - this.silver;
            }
            return o.gold - this.gold;
        }
    }
}

μ„œν‰ μ™„λ£Œ λͺ©λ‘

μ„œν‰ μ˜ˆμ • λͺ©λ‘ (μ½λŠ” 쀑)

  • ν”„λ‘œκ·Έλž˜λ¨Έμ˜ κΈΈ, λ©˜ν† μ—κ²Œ 묻닀
  • ν•¨κ»˜ 자라기 μ• μžμΌλ‘œ κ°€λŠ” κΈΈ

λ…μ„œ μ˜ˆμ • λͺ©λ‘

λͺ©λ‘μ€ μš°μ„ μˆœμœ„ 큐이닀. 상단에 μžˆλ”λΌλ„ 더 μ€‘μš”ν•œ 책이 λ“€μ–΄μ˜¨λ‹€λ©΄ μˆœμœ„κ°€ λ’€λ‘œ 밀릴 수 μžˆλ‹€.

  • 객체지ν–₯의 사싀과 μ˜€ν•΄
  • 였브젝트
  • 파이브 라인슀 였브 μ½”λ“œ
  • HTTP μ™„λ²½ κ°€μ΄λ“œ
  • μžλ°”/μŠ€ν”„λ§ 개발자λ₯Ό μœ„ν•œ μ‹€μš©μ£Όμ˜ ν”„λ‘œκ·Έλž˜λ°
  • λͺ¨λ˜ μžλ°” 인 μ•‘μ…˜
  • μžλ°” μ„±λŠ₯ νŠœλ‹ 이야기
  • μžλ°” κ°œλ°œμžμ™€ μ‹œμŠ€ν…œ 운영자λ₯Ό μœ„ν•œ νŠΈλŸ¬λΈ” μŠˆνŒ… 이야기 / scouterλ₯Ό ν™œμš©ν•œ μ‹œμŠ€ν…œ μž₯μ•  진단 및 ν•΄κ²° λ…Έν•˜μš° μžλ°” νŠΈλŸ¬λΈ”μŠˆνŒ…
  • ν—€λ“œ 퍼슀트 μ„œλΈ”λ¦Ώ
  • Hello Coding 그림으둜 κ°œλ…μ„ μ΄ν•΄ν•˜λŠ” μ•Œκ³ λ¦¬μ¦˜
profile
What doesn't kill you, makes you stronger

0개의 λŒ“κΈ€