목록전체 글 (130)
csct3434
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.stream.IntStream; class Solution { private int answer = 0; public int solution(int k, int[][] dungeons) { int total = dungeons.length; boolean[] visited = new boolean[total]; solve(total, 0, 0, visited, dungeons, k); return answer; } private void solve(int total, ..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int[] solution(int n, long left, long right) { int[] answer = new int[(int) (right - left + 1)]; int count = 0; for (long num = left; num = base) { answer[count] += (int) (rem - base + 1); } } return answer; } }
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int solution(int n, int[][] wires) { int answer = n; int[] count = new int[n + 1]; boolean[] visited = new boolean[n + 1]; boolean[][] adjacentMatrix = new boolean[n + 1][n + 1]; initAdjacentMatrix(adjacentMatrix, wires); dfs(n, 1, count, visited, adjacentM..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.LinkedList; import java.util.List; class Solution { public int solution(String word) { List dictionary = new LinkedList(); initDictionary("", 0, dictionary); return dictionary.indexOf(word) + 1; } private void initDictionary(String word, int depth, List dictionary..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public long[] solution(long[] numbers) { long[] answer = new long[numbers.length]; int index = 0; for (long number : numbers) { if (number % 2 == 0) { answer[index++] = number + 1; continue; } String binaryString = Long.toBinaryString(number); int idx = binaryStri..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int[] solution(int rows, int columns, int[][] queries) { int[] answer = new int[queries.length]; int[][] arr = new int[rows][columns]; int count = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { arr[i][j] = ++count; } } count = 0; fo..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.HashMap; import java.util.Stack; class Solution { private final HashMap map = new HashMap(); public int solution(String s) { int answer = 0; map.put('(', 1); map.put('{', 2); map.put('[', 3); map.put(')', -1); map.put('}', -2); map.put(']', -3); StringBuilder stri..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map.Entry; class Solution { public String[] solution(String[] orders, int[] course) { HashMap combinations = new HashMap(); for (St..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int[] solution(String s) { int rep = 0; int count = 0; while (!s.equals("1")) { rep++; String sWithoutZero = s.replace("0", ""); count += s.length() - sWithoutZero.length(); s = Integer.toBinaryString(sWithoutZero.length()); } return new int[]{rep, count}; ..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { private int[] count = new int[2]; public int[] solution(int[][] arr) { solve(arr, 0, 0, arr.length); return count; } private void solve(int[][] arr, int x, int y, int size) { if (isCompressible(arr, x, y, size)) { count[arr[x][y]]++; return; } size /= 2; solve(arr..