Algorithm (PS)63 [프로그래머스 Level 1] 콜라 문제 (Java) 문제 https://school.programmers.co.kr/learn/courses/30/lessons/132267 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 class Solution { public int solution(int a, int b, int n) { int answer = 0; while(n>=a){ //얻은 콜라 수 구하기 int cnt=b*(n/a); answer+=cnt; //남은 콜라수 구하기 n=n%a; n+=cnt; } return answer; } } 2023. 8. 29. [프로그래머스 Level 1] 푸드 파이트 대회 (Java) 문제 https://school.programmers.co.kr/learn/courses/30/lessons/134240 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 class Solution { public String solution(int[] food) { String answer = ""; StringBuilder sb = new StringBuilder(); for(int i=0; i 2023. 8. 29. [프로그래머스 Level 1] 가장 가까운 같은 글자(Java) 문제 https://school.programmers.co.kr/learn/courses/30/lessons/142086 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이 1. 2중 for문을 통해 글자를 찾는다 2. 가까운 글자를 찾으면 break 시켜주고 현재 인덱스에서 찾은 인덱스를 빼 answer 배열에 넣는다. 3. 글자를 찾지 못하면 -1을 answer 배열에 넣는다. 코드 class Solution { public int[] solution(String s) { int[] answer = new int[s.length()]; for(int .. 2023. 8. 29. [프로그래머스 Level 1] 두 개 뽑아서 더하기(Java) 문제 https://school.programmers.co.kr/learn/courses/30/lessons/68644 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import java.util.*; class Solution { public int[] solution(int[] numbers) { ArrayList list = new ArrayList(); for(int i=0; i 2023. 8. 28. [프로그래머스 Level 1] K번째수(Java) 문제 https://school.programmers.co.kr/learn/courses/30/lessons/42748 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import java.util.*; class Solution { public int[] solution(int[] array, int[][] commands) { int[] answer = new int[commands.length]; for(int i=0; i 2023. 8. 26. [프로그래머스 Level 1] 문자열 내 마음대로 정렬하기(Java) 문제 https://school.programmers.co.kr/learn/courses/30/lessons/12915 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import java.util.*; class Solution { public String[] solution(String[] strings, int n) { String[] answer = {}; Arrays.sort(strings, new Comparator(){ @Override public int compare(String s1, String s2){ if(s1.charAt(n).. 2023. 8. 26. 이전 1 2 3 4 ··· 11 다음