본문 바로가기

프로그래머스23

[코딩 기초 트레이닝] 0 떼기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181847 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public String solution(String n_str) { while(n_str.substring(0,1).equals("0")) { n_str = n_str.substring(1,n_str.length()); } return n_str; } } 다른 사람 풀이 : class Solution { public String solution(.. 2024. 2. 10.
[코딩 기초 트레이닝] 왼쪽 오른쪽 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181890 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public String[] solution(String[] str_list) { String[] answer = {}; for (int i = 0; i < str_list.length;i++) { if (str_list[i].equals("l")) { return Arrays.copyOfRange(str_lis.. 2024. 1. 23.
[코딩 기초 트레이닝] 문자열 바꿔서 찾기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181864 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 틀렸던 해결 방안 : class Solution { public int solution(String myString, String pat) { int answer = 0; String[] str = myString.split(""); for(int i = 0; i 2024. 1. 14.
[코딩 기초 트레이닝] 특정 문자열로 끝나는 가장 긴 부분 문자열 찾기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181872 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public String solution(String myString, String pat) { String fin = ""; int num = myString.lastIndexOf(pat); fin = myString.substring(0, num) + pat; return fin; } } 2024. 1. 4.
[코딩 기초 트레이닝] 길이에 따른 연산 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181879 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int solution(int[] num_list) { int answer = 0; if(num_list.length > 10){ for(int sum : num_list) answer += sum; }else{ answer = 1; for(int multi : num_list) answer *= multi; } return answe.. 2024. 1. 2.
[코딩 기초 트레이닝] 조건에 맞게 수열 변환하기 2 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181881 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int solution(int[] arr) { int[] before = new int[arr.length]; int cnt = 0; int answer = 0; while(cnt != arr.length){ cnt = 0; before = arr.clone(); for(int i = 0; i=50 && arr[i]%2 == 0){ a.. 2024. 1. 2.
[코딩 기초 트레이닝] 소문자로 바꾸기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181850 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public String solution(String myString) { String answer = ""; answer = myString.toLowerCase(); return answer; } } 2024. 1. 1.
[코딩 기초 트레이닝] 대문자로 바꾸기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181877 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public String solution(String myString) { String answer = ""; answer = myString.toUpperCase(); return answer; } } 2024. 1. 1.
[코딩 기초 트레이닝] 원하는 문자열 찾기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181878 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int solution(String myString, String pat) { int answer = 0; if(myString.toLowerCase().contains(pat.toLowerCase())) answer = 1; return answer; } } 2024. 1. 1.
[코딩 기초 트레이닝] 조건에 맞게 수열 변환하기 1 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181882 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int[] solution(int[] arr) { int[] answer = new int[arr.length]; for(int i =0; i= 50 && arr[i]%2 == 0 ){ answer[i] = arr[i]/2; }else if(arr[i] < 50 && arr[i]%2 != 0){ answer[i] = arr[i]*2; .. 2024. 1. 1.
[코딩 기초 트레이닝] 수열과 구간 쿼리 1 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181883 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int[] solution(int[] arr, int[][] queries) { int s = 0; int e = 0; for(int i =0; i 2024. 1. 1.
[코딩 기초 트레이닝] n보다 커질 때까지 더하기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/181884 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int solution(int[] numbers, int n) { int sum = 0; for(int i = 0; i n ){ return sum; } } return sum; } } 복붙하니까 들여쓰기 난감;;하지만 귀찮으니 패스~ 하지만 개발할 때는 이렇게 하면 혼납니다 ㅎㅎ.. if문에서 걸리지 않으면 return하는 부분이 없.. 2023. 12. 28.