[백준] Silver II. 부분수열의 합
·
Algorithm/백준
https://www.acmicpc.net/problem/1182 알고리즘백트래킹풀이import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.StringTokenizer;public class Main { static int n, s; static int [] arr; static int count = 0; static boolean [] visited; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(ne..
[백준] Gold IV. N-Queen
·
Algorithm/백준
https://www.acmicpc.net/problem/9663 사용 알고리즘백트래킹풀이import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.*;public class Main { static int n; static int [] arr; static int count = 0; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); n = ..
[백준] Silver.1 연산자 끼워넣기
·
Algorithm/백준
https://www.acmicpc.net/problem/14888 사용 알고리즘백트래킹재귀풀이import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.*;public class Main { static int n; static int [] nums; static int [] cal = new int [4]; static int max = Integer.MIN_VALUE; static int min = Integer.MAX_VALUE; public static void main(String[] args) throws IOException {..
[프로그래머스] Lv.2 요격 시스템
·
Algorithm/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/181188 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 사용 알고리즘그리디 알고리즘정렬풀이import java.util.*;class Solution { public int solution(int[][] targets) { int answer = 0; Arrays.sort(targets, (a,b) -> a[1] - b[1]); int before = 0; for(int [] targ..
[백준] Gold 4 카드 정렬하기
·
Algorithm/백준
https://www.acmicpc.net/problem/1715 사용 알고리즘우선순위 큐 풀이import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.*;public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); // 10만 , 제한시간 2초 ..
[백준] Silver 1 절댓값 힙
·
Algorithm/백준
https://www.acmicpc.net/problem/11286  import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.*;public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); PriorityQueue pq = new PriorityQ..
[프로그래머스] Lv.2 디펜스 게임
·
Algorithm/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/142085 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 이전 제출 답안import java.util.*;class Solution { public int solution(int n, int k, int[] enemy) { int answer = 0; // min = 1, max = 5 mid = 3 // 10만 * int [] tmp = Arrays.copyOf(enemy, enem..
[프로그래머스] Lv.1 완주하지 못한 선수
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/42576 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 문제 접근 방법1. 참가자들의 이름과 등장횟수를 해쉬맵에 담아준다.2. 완주자들을 순회하며 해쉬맵에서 등장횟수 - 1을 해준다.3. 마지막으로 해쉬맵의 value값을 순회할 때 0이 아닌 값이 있다면, 해당 Key를 리턴해준다.import java.util.*;class Solution { public String solution(String[] participant, String[] compl..
[프로그래머스] Lv.1 없는 숫자 더하기
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/86051?language=java 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  class Solution { public int solution(int[] numbers) { int answer = 0; boolean[] visited = new boolean[10]; for(int num : numbers) { visited[num] = true; } ..
[프로그래머스] Lv.0 A로 B 만들기
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/120886 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 풀이 접근 방법1. 해쉬맵을 선언해서 각 문자열의 문자, 등장횟수를 저장한다.2. 해쉬맵을 비교하여 다르다면 0을 리턴하고, 전부 같다면 1을 리턴한다.import java.util.*;class Solution { public int solution(String before, String after) { Map m1 = new HashMap(); Map m2 = ne..