목록전체 글 (130)
csct3434
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int solution(int n, int a, int b) { int answer = 0; while (true) { answer++; a = (a + 1) / 2; b = (b + 1) / 2; if (a == b) { break; } } return answer; } }
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int[] solution(int n, String[] words) { HashSet usedWords = new HashSet(); char lastCharacter = words[0].charAt(0); for (int i = 0; i < words.length; i++) { String word = words[i]; if (usedWords.contains(word) || word.charAt(0) != lastCharacter) { return ne..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr public class Solution { public int solution(int n) { if (n
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int solution(int N, int[][] road, int K) { List graph = new ArrayList(); int[] distance = new int[N + 1]; init(graph, distance, road, N); PriorityQueue pq = new PriorityQueue(Comparator.comparingInt(a -> a[1])); pq.add(new int[]{1, 0}); while (!pq.isEmpty()..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int solution(String s) { Stack stack = new Stack(); for (char c : s.toCharArray()) { if (!stack.isEmpty() && stack.peek().equals(c)) { stack.pop(); continue; } stack.push(c); } return stack.isEmpty() ? 1 : 0; } }
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int solution(int[] arr) { int LCM = lcm(arr[0], arr[1]); for (int i = 2; i b) { int temp = a; a ..
문제 링크 class Solution { private int[][] isBlocked; private int size, answer = 0; public int solution(int n) { init(n); solve(0); return answer; } private void init(int n) { size = n; isBlocked = new int[n][n]; } public void solve(int row) { if (row == size) { answer++; return; } for (int col = 0; col < size; col++) { if (isBlocked[row][col] == 0) { setBlocked(row, col, true); solve(row + 1); setB..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public String solution(String s) { StringBuilder answer = new StringBuilder(); boolean isBehindWhiteSpace = true; for(String token : s.toLowerCase().split("")) { answer.append(isBehindWhiteSpace? token.toUpperCase() : token); isBehindWhiteSpace = token.equals(" ")..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int[][] solution(int[][] arr1, int[][] arr2) { int l = arr1.length; int m = arr1[0].length; int n = arr2[0].length; int[][] answer = new int[l][n]; for (int i = 0; i < l; i++) { for (int k = 0; k < n; k++) { int sum = 0; for (int j = 0; j < m; j++) { sum +=..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { private List result = new ArrayList(); public int[][] solution(int n) { move(n, 1, 3, 2); int[][] answer = new int[result.size()][2]; for (int i = 0; i < result.size(); i++) { answer[i] = result.get(i); } return answer; } public void move(int count, int from, int ..