프로그래머스

가운데 글자 가져오기/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12903 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫 풀이 (2020.04.26) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Solution { public String solution(String s) { String answer = ""; if (s.length()%2!=0) answer += s.charAt(s.length()/2); else { answer += s.charAt(s.length()/2-1); answer +=..

제일 작은 수 제거하기/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12935 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫 시도 (실패) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import java.util.*; class Solution { public int[] solution(int[] arr) { int[] answer = new int[arr.length - 1]; Arrays.sort(arr); int[] temp = Arrays.copyOfRange(arr,..

짝수와 홀수/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12937 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫 풀이 (2020.03.17) 1 2 3 4 5 6 7 8 9 10 11 12 class Solution { public String solution(int num) { String answer = ""; if(num%2==0){ answer = "Even"; }else answer = "Odd"; return answer; } } Colored by Color Scripter cs 재 풀이 (2020.04..

핸드폰 번호 가리기/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12948 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫 풀이 (2020.04.21) 1 2 3 4 5 6 7 8 9 10 11 12 class Solution { public String solution(String phone_number) { String answer = ""; for(int i=0;i

x만큼 간격이 있는 n개의 숫자/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12954 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫 풀이 (2020.04.20) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Solution { public long[] solution(int x, int n) { long[] answer = new long[n]; long temp = x; for(int i=0;i

서울에서 김서방 찾기/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12919 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫 풀이 (2020.04.19) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class Solution { public String solution(String[] seoul) { String answer = ""; for(int i=0;i

문자열 다루기 기본/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12918 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫 풀이 (2020.03.19) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 class Solution { public boolean solution(String s) { boolean answer = true; if((s.length() == 4 || s.length() == 6)) { for(int i=0;i= 'a' && s.charAt(i) = 'A' && s.charAt..

두 정수 사이의 합/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12912 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫 풀이 (2020.03.26) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 class Solution { public long solution(int a, int b) { long answer = 0; // 합 if(a>b) { for(int i=b;i

문자열 내 마음대로 정렬하기/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12915 코딩테스트 연습 - 문자열 내 마음대로 정렬하기 | 프로그래머스 문자열로 구성된 리스트 strings와, 정수 n이 주어졌을 때, 각 문자열의 인덱스 n번째 글자를 기준으로 오름차순 정렬하려 합니다. 예를 들어 strings가 [sun, bed, car]이고 n이 1이면 각 단어의 인덱스 1의 문자 u, e, a로 strings를 정렬합니다. 제한 조건 strings는 길이 1 이상, 50이하인 배열입니다. strings의 원소는 소문자 알파벳으로 이루어져 있습니다. strings의 원소는 길이 1 이상, 100이하인 programmers.co.kr ○ 처음 푼 풀이 1 2 3 4 5 6 7 8 9 10..

같은 숫자는 싫어/java/프로그래머스/Level1
https://programmers.co.kr/learn/courses/30/lessons/12906 코딩테스트 연습 - 같은 숫자는 싫어 | 프로그래머스 배열 arr가 주어집니다. 배열 arr의 각 원소는 숫자 0부터 9까지로 이루어져 있습니다. 이때, 배열 arr에서 연속적으로 나타나는 숫자는 하나만 남기고 전부 제거하려고 합니다. 단, 제거된 후 남은 수들을 반환할 때는 배열 arr의 원소들의 순서를 유지해야 합니다. 예를 들면, arr = [1, 1, 3, 3, 0, 1, 1] 이면 [1, 3, 0, 1] 을 return 합니다. arr = [4, 4, 4, 3, 3] 이면 [4, 3] 을 retur programmers.co.kr ○ 처음 푼 풀이 (2020.02.23) 1 2 3 4 5 6 7..