본문 바로가기

코딩테스트/programmers11

프로그래머스 [#12] 코딩테스트 연습 JAVA - 12 1. N개의 최소공배수 https://school.programmers.co.kr/learn/courses/30/lessons/12953 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public int solution(int[] arr) { int answer = 0; int first = arr[0]; int second; //max_divisor 최대공약수 int max_divisor = 1; for(int i = 1; i < arr.length; ++i){ max_divisor = .. 2023. 2. 22.
프로그래머스 [#11] 코딩테스트 연습 JAVA - 11 1. 영어 끝말잇기 https://school.programmers.co.kr/learn/courses/30/lessons/12981?language=java 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public int[] solution(int n, String[] words) { //탈락자가 발생하지 않는 경우 int[] answer = {0,0}; int index = 0; //중복 체크를 하기 위해 LinkedList link = new LinkedList(); link.add.. 2023. 2. 16.
프로그래머스 [#10] 코딩테스트 연습 JAVA - 10 1. 크기가 작은 부분문자열 https://school.programmers.co.kr/learn/courses/30/lessons/147355 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int solution(String t, String p) { int answer = 0; for(int i = 0; i < t.length() - p.length() + 1; ++i){ if(Long.parseLong(t.substring(i,i+p.length())) 2023. 2. 8.
프로그래머스 [#9] 코딩테스트 연습 JAVA - 9 1. 점프와 순간 이동 https://school.programmers.co.kr/learn/courses/30/lessons/12980 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; public class Solution { public int solution(int n) { int cnt = 0; while (n !=0) { //n이 0이 아닐때 까지 if (n % 2 == 0) { n /= 2; //나누어 떨어지면 } else { n--; // 안나누어 떨어지면 1빼고 cnt++; // cnt 하나 추가 } } r.. 2023. 2. 1.
프로그래머스 [#8] 코딩테스트 연습 JAVA - 8 1. 2016년 https://school.programmers.co.kr/learn/courses/30/lessons/12901 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution{ public String solution(int a, int b){ int c = 0; String[] day = {"THU", "FRI","SAT","SUN","MON","TUE","WED"}; int[] month = {31,29,31,30,31,30,31,31,30,31,30,31}; if(a == 1) c = b; else{ for(int i =.. 2023. 1. 11.
프로그래머스 [#7] 코딩테스트 연습 JAVA - 7 1. 문자열 내 마음대로 정렬하기 https://school.programmers.co.kr/learn/courses/30/lessons/12915?language=java 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public String[] solution(String[] strings, int n) { String[] answer = new String[strings.length]; Arrays.sort(strings); //정렬 ArrayList arr = new ArrayLis.. 2023. 1. 5.