[프로그래머스] Lv.2 게임 맵 최단 거리
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/1844BFS 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 사용 알고리즘BFS풀이import java.util.*;class Solution { static int [] dx = {1,0,-1,0}; static int [] dy = {0,1,0,-1}; public int solution(int[][] maps) { int n = maps.length; int m = maps[0].length; int [][] ..
[프로그래머스] Lv.3 단어 변환
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/43163/ 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 사용 알고리즘BFSDFS풀이BFS를 사용한 풀이 import java.util.*;class Solution { public int solution(String begin, String target, String[] words) { int answer = 0; boolean [] visited = new boolean[words.length]; Qu..
[프로그래머스] Lv.2 기능개발
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/42586 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  사용 알고리즘배열 큐풀이 import java.util.*;class Solution { public int[] solution(int[] progresses, int[] speeds) { int [] complete = new int[progresses.length]; for(int i = 0; i list = new ArrayList(..
[프로그래머스] Lv.2 주식 가격
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/42584 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  사용 알고리즘 스택풀이 import java.util.*;class Solution { public int[] solution(int[] prices) { int[] answer = new int[prices.length]; // 1. 다음 값이 현재 값보다 작을 때 // 2. 다음 값이 현재 값보다 클 때 -> ..
[프로그래머스] Lv.2 괄호 회전하기
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/76502 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 사용 알고리즘스택문자열 분할풀이 import java.util.Stack;class Solution { static int answer = 0; public int solution(String s) { for(int i = 0; i stack = new Stack(); for(char c : tmp.toCharArray()) { ..
[프로그래머스] Lv.2 올바른 괄호
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/12909 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 사용 알고리즘스택풀이 import java.util.*;class Solution { boolean solution(String s) { Stack stack = new Stack(); for(char c : s.toCharArray()) { if (!stack.isEmpty()) { if (stack.peek..
[프로그래머스] 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..
[프로그래머스] Lv.0 중복된 문자 제거
·
Algorithm/프로그래머스 코딩테스트 문제풀이전략
https://school.programmers.co.kr/learn/courses/30/lessons/120888 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 내 풀이import java.util.*;class Solution { public String solution(String my_string) { String answer = ""; LinkedHashSet set = new LinkedHashSet(); for(char c : my_string.toCharArray()) { ..