직업군 추천하기

직업군 추천하기

728x90

package prog; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class 직업군_추천하기 { public static void main(String[] args) { SolutionC s = new SolutionC(); System.out.println( s.solution(new String[] {"SI JAVA JAVASCRIPT SQL PYTHON C#", "CONTENTS JAVASCRIPT JAVA PYTHON SQL C++", "HARDWARE C C++ PYTHON JAVA JAVASCRIPT", "PORTAL JAVA JAVASCRIPT PYTHON KOTLIN PHP", "GAME C++ C# JAVASCRIPT C JAVA"}, new String[] {"PYTHON", "C++", "SQL"}, new int[] {7, 5, 5} ) ); } } class SolutionC{ static int row; static int col= 5; public String solution(String[] table, String[] languages, int[] preference) { String answer = ""; StringTokenizer st = new StringTokenizer(table[0]," "); row = table.length; col = st.countTokens(); HashMap dict = new HashMap<>(); String[][] board = new String[row][col]; for (int i = 0; i < table.length; i++) { st = new StringTokenizer(table[i]," "); String team = st.nextToken(); board[i][0]=team; dict.put(team,0); for (int j = 1; j < col; j++) { board[i][j] = st.nextToken(); } } for (int i = 0; i < row; i++) { for (int j = 1; j < col; j++) { for (int z=0;z{ String name; int score; public Team(String name, int score) { this.name = name; this.score = score; } @Override public int compareTo(Team o) { if(this.score!=o.score) return -(this.score-o.score); else{ return this.name.compareTo(o.name); } } }

728x90

from http://arch1tect.tistory.com/105 by ccl(A) rewrite - 2021-09-03 23:26:29