완전탐색(3)
-
프로그래머스 - DFS - 네트워크
programmers.co.kr/learn/courses/30/lessons/43162 코딩테스트 연습 - 네트워크 네트워크란 컴퓨터 상호 간에 정보를 교환할 수 있도록 연결된 형태를 의미합니다. 예를 들어, 컴퓨터 A와 컴퓨터 B가 직접적으로 연결되어있고, 컴퓨터 B와 컴퓨터 C가 직접적으로 연결되어 있 programmers.co.kr public class 네트워크 { public static void main(String[] args) { 네트워크 o = new 네트워크(); System.out.println(o.solution(3, new int[][]{{1, 1, 0}, {1, 1, 0}, {0, 0, 1}})); } private boolean[] isVisit; private int[][] ..
2021.03.15 -
프로그래머스 - DFS - 타겟 넘버
programmers.co.kr/learn/courses/30/lessons/43165 코딩테스트 연습 - 타겟 넘버 n개의 음이 아닌 정수가 있습니다. 이 수를 적절히 더하거나 빼서 타겟 넘버를 만들려고 합니다. 예를 들어 [1, 1, 1, 1, 1]로 숫자 3을 만들려면 다음 다섯 방법을 쓸 수 있습니다. -1+1+1+1+1 = 3 +1-1+1+1+ programmers.co.kr import java.util.Stack; public class 타겟_넘버 { public static void main(String[] args) { 타겟_넘버 o = new 타겟_넘버(); System.out.println(o.solution(new int[]{1,1,1,1,1}, 3)); } private stati..
2021.03.15 -
프로그래머스 - 완전탐색 - 카펫
programmers.co.kr/learn/courses/30/lessons/42842 코딩테스트 연습 - 카펫 Leo는 카펫을 사러 갔다가 아래 그림과 같이 중앙에는 노란색으로 칠해져 있고 테두리 1줄은 갈색으로 칠해져 있는 격자 모양 카펫을 봤습니다. Leo는 집으로 돌아와서 아까 본 카펫의 노란색과 programmers.co.kr import java.util.Arrays; public class 카펫 { public static void main(String[] args) { 카펫 o = new 카펫(); System.out.println(Arrays.toString(o.solution(10, 2))); } public int[] solution(int brown, int yellow) { int..
2021.03.12