본문 바로가기

프로그래머스77

신고 결과 받기 풀이 import java.util.*; class Solution { public int[] solution(String[] id_list, String[] report, int k) { int[] answer = new int[id_list.length]; Map map = new HashMap(); Map idxMap = new HashMap(); for (int i = 0; i < id_list.length; i++) { String name = id_list[i]; map.put(name, new HashSet()); idxMap.put(name, i); } for (String s : report) { String[] str = s.split(" "); String from = str[0]; ..
성격 유형 검사하기 풀이 class Solution { public String solution(String[] survey, int[] choices) { int C = 0, F = 0, M = 0, J = 0, N = 0, A = 0, T = 0, R = 0; int[] score = { 3, 2, 1, 0, 1, 2, 3}; for (int i = 0; i < choices.length && i < survey.length; i++) { int choice = choices[i]; char firstChar = survey[i].charAt(0); char secondChar = survey[i].charAt(1); int categoryScore = score[choice -1]; // 각 카테고리에 대한 점수 업데..
숫자 짝꿍 풀이 class Solution { public String solution(String X, String Y) { StringBuilder answer = new StringBuilder(); int[] x = {0,0,0,0,0,0,0,0,0,0}; int[] y = {0,0,0,0,0,0,0,0,0,0}; for(int i=0; i
삼총사 풀이 class Solution { public int solution(int[] number) { int answer = 0; for(int i=0; i
콜라 문제 풀이 class Solution { public int solution(int a, int b, int n) { int count = 0; int num = n; while(num >= a) { count += num / a * b; num = num / a * b + num % a; } return count; } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr
옹알이 (2) 풀이 class Solution { public int solution(String[] babbling) { int answer = 0; for (String s : babbling) { s = s.replaceAll("ayaaya|yeye|woowoo|mama", " "); s = s.replaceAll("aya|ye|woo|ma", ""); if (s.equals("")) answer++; } return answer; } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr