본문 바로가기

전체 글206

[코딩 기초 트레이닝] 부분 문자열인지 확인하기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181843 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int solution(String my_string, String target) { if(my_string.contains(target)){ return 1; }else{ return 0; } } } 2024. 2. 7.
[코딩 기초 트레이닝] 문자열을 정수로 변환하기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181848 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int solution(String n_str) { return Integer.parseInt(n_str); } } 2024. 2. 6.
[코딩 기초 트레이닝] 문자열 정수의 합 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181849 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int solution(String num_str) { String[] arr =num_str.split(""); int[] num = new int[arr.length]; int sum = 0; for(int i =0; i 2024. 2. 6.
[코딩 기초 트레이닝] 뒤에서 5등 위로 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181852 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public int[] solution(int[] num_list) { Arrays.sort(num_list); int[] arr = new int[num_list.length-5]; for(int i = 0; i 2024. 2. 6.
[코딩 기초 트레이닝] 문자열 묶기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181855 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.HashMap; import java.util.Map; class Solution { public int solution(String[] strArr) { int max = 0; Map group = new HashMap(); for(String str : strArr){ int len = str.length(); group.put(len, gro.. 2024. 2. 6.
[코딩 기초 트레이닝] 뒤에서 5등까지 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181853 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public int[] solution(int[] num_list) { return Arrays.stream(num_list).sorted().limit(5).toArray(); } } 다른 사람 풀이 : import java.util.Arrays; class Solution { public int[] solut.. 2024. 2. 6.
[코딩 기초 트레이닝] 배열의 길이에 따라 다른 연산하기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181854 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int[] solution(int[] arr, int n) { int len = arr.length; if(len%2 == 0){ for(int i = 0; i 2024. 2. 6.
[코딩 기초 트레이닝] 배열 비교하기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181856 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public int solution(int[] arr1, int[] arr2) { int sum1 = 0; int sum2 = 0; if(arr1.length arr2.length){ return 1; }else{ sum1 .. 2024. 2. 5.
[코딩 기초 트레이닝] 배열의 길이를 2의 거듭제곱으로 만들기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181857 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public int[] solution(int[] arr) { int length = 1; while (length < arr.length) { length *= 2; } return Arrays.copyOf(arr, length); } } 다른 사람 풀이 : class Solution { public int[].. 2024. 2. 5.
[코딩 기초 트레이닝] 무작위로 K개의 수 뽑기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181858 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public int[] solution(int[] arr, int k) { List answer = new ArrayList(); for(int i = 0; ii).toArray(); } } 2024. 2. 5.
[코딩 기초 트레이닝] 배열 만들기6 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181859 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public int[] solution(int[] arr) { List stk = new ArrayList(); int i = 0; while(i< arr.length){ if(stk.size() == 0){ stk.add(arr[i]); i++; }else if(stk.get(stk.size()-1) == ar.. 2024. 2. 4.
[코딩 기초 트레이닝] 빈 배열에 추가, 삭제하기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181860 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public int[] solution(int[] arr, boolean[] flag) { List x = new ArrayList(); for(int i = 0; i 2024. 2. 4.