구현
-
[Programmers] 거리두기 확인하기 / ⭕Algorithm/Programmers 2024. 10. 8. 16:12
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (1시간 20분 14초 / 구현)import java.util.*;class Solution { public int[] solution(String[][] places) { int[] answer = new int[5]; Arrays.fill(answer, 1); for(int i = 0; i 4 || ny 4) { continue; } if(plac..
-
[Programmers] 주차 요금 계산 / ⭕Algorithm/Programmers 2024. 10. 7. 15:45
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (1시간 20분 30초 / 정렬, 구현)import java.util.*;class Solution { public int[] solution(int[] fees, String[] records) { ArrayList ans = new ArrayList(); Map map = new HashMap(); // 정렬 Arrays.sort(records, (o1, o2) -> { String[] os1 = o1.s..
-
[Programmers] 우박수열 정적분 / ⭕Algorithm/Programmers 2024. 10. 6. 11:03
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (50분 37초 / 구현)import java.util.*;class Solution { static ArrayList arr = new ArrayList(); static double[] size; public double[] solution(int k, int[][] ranges) { double[] answer = new double[ranges.length]; collatz(k); size = new double[arr.size(..
-
[Programmers] 점 찍기 / ❌Algorithm/Programmers 2024. 10. 5. 18:13
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (1시간 12분 28초 / 구현)import java.util.*;class Solution { public long solution(int k, int d) { long answer = 0; for(int i = 0; i 2. 구현 로직X를 K만큼 증가시키면서 주어진 D값과 피타고라스 정리를 이용해서 Y값을 구해보려고 한다.getY함수에 X와 D 값을 넣게 되면 Y값이 구해지게 되는데 Y는 D거리 안에서 최대 값이다.이 값을 getCnt에 넣어서 K로 나누고 + ..
-
[Programmers] 테이블 해시 함수 / ⭕Algorithm/Programmers 2024. 10. 4. 23:07
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (14분 32초 / 정렬, 구현)import java.util.*;class Solution { public int solution(int[][] data, int col, int row_begin, int row_end) { int answer = 0; Arrays.sort(data, (o1, o2) -> { if(o1[col - 1] == o2[col - 1]) { return o2[0] - o1[0]; ..
-
[Programmers] 연속 부분 수열 합의 개수 / ⭕Algorithm/Programmers 2024. 10. 3. 23:40
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (21분 32초 / 구현)import java.util.*;class Solution { public int solution(int[] elements) { int answer = 0; Set set = new HashSet(); for(int i = 1; i = elements.length) { idx = 0; } temp += e..
-
[BOJ - Silver V] 그룹 단어 체커 / ⭕Algorithm/BOJ 2024. 8. 20. 22:50
그룹 단어 체커1. 제출 코드 (12분 23초 / 구현)import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.HashMap;import java.util.Map;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()); int answer =..
-
[BOJ - Silver V] 무한 문자열 / ⭕Algorithm/BOJ 2024. 8. 17. 12:01
무한 문자열 1. 제출 코드 (27분 55초 / 구현)import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); String t = br.readLine(); int answer = 1; String ts = s.conc..