분류 전체보기(119)
-
[프로그래머스] 타겟넘버 문제 풀이(DFS BFS 재귀함수 Lv. 2) - java 자바
0. 자세한 설명은 YouTube 영상으로 개발자로 취직하기의 DFS 강의 : https://inf.run/MqJT [자바/Java] 문과생도 이해하는 DFS 알고리즘! - 입문편 - 인프런 | 강의 자바(Java)로 코딩테스트를 준비하시는 DFS로 분들이 가장 많다는 소식을 들어 제작된 강의입니다 :) 문과 출신의 현업 개발자가 공부한 방식 그대로 설명하고, 지루한 이론 강의는 다 직접 문제를 www.inflearn.com 1. DFS(재귀함수)를 활용한 Solution class Solution { int answer; public int solution(int[] numbers, int target) { answer = 0; dfs(0, 0, numbers, target); return answer..
2022.03.30 -
[백준 1018] 체스판 다시 칠하기 (완전탐색) - java 자바
0. 자세한 설명은 YouTube 영상으로 1-1. 완전탐색 Solution import java.util.Scanner; class Main { public static int getSolution(int startRow, int startCol, String[] board) { String[] orgBoard = { "WBWBWBWB", "BWBWBWBW" }; int whiteSol = 0; for (int i = 0; i < 8; i++) { int row = startRow + i; for (int j = 0; j < 8; j++) { int col = startCol + j; if (board[row].charAt(col) != orgBoard[row % 2].charAt(j)) whiteSo..
2022.03.07 -
[2022 카카오 코딩테스트] 신고 결과 받기 - 자바 java (Hash, 해시)
0. 자세한 설명은 YouTube 영상으로 1. Hash를 활용한 solution import java.util.*; class Solution { public int[] solution(String[] id_list, String[] report, int k) { int[] answer = new int[id_list.length]; // 1. 중복 제거 HashSet reportSet = new HashSet(); for (String rep : report) reportSet.add(rep); // 2. report에서 각 사람이 신고당한 횟수를 countHash으로 정의하기 HashMap notifyListHash = new HashMap(); for (String rep : reportSet){..
2022.02.16 -
[2021 카카오 코딩테스트] 키패드 누르기 - 자바 java
0. 자세한 설명은 YouTube 영상으로 1. Class를 활용한 solution class Solution { Position left; Position right; Position numPos; public String solution(int[] numbers, String hand) { String answer = ""; // 1. 왼손 오른손 위치 초기화 left = new Position(3, 0); right = new Position(3, 2); for (int num : numbers) { // 2. 숫자를 누를 손가락 정하기 numPos = new Position((num - 1) / 3, (num - 1) % 3); if (num == 0) numPos = new Position(3,..
2022.01.21 -
[2021 카카오 코딩테스트] 순위 검색 - 자바 java
0. 자세한 설명은 YouTube 영상으로 1. Hash + 이분 탐색을 활용한 solution import java.util.*; class Solution { public int[] solution(String[] info, String[] query) { // 1. info를 기반으로 hashMap 만들기 HashMap hashMap = new HashMap(); for (String i : info) { String[] data = i.split(" "); String[] languages = { data[0], "-" }; String[] jobs = { data[1], "-" }; String[] exps = { data[2], "-" }; String[] foods = { data[3], "..
2021.12.29 -
[2021 카카오 코딩테스트] 메뉴 리뉴얼 - 파이썬
0. 자세한 설명은 YouTube 영상으로 1-1. Hash를 활용한 Solution from itertools import combinations def solution(orders, course): answer = [] # 1. 각 order 정렬 for i in range(len(orders)): orders[i] = "".join(sorted(orders[i])) print(orders[i]) # 2. course_len 마다 조합 생성 for course_len in course: hash = {} max = 0 for order in orders: # 각 Order를 기준으로 courseLength 만큼의 조합 만들기 for comb in combinations(order, course_len..
2021.12.27