Coding Test

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 음양 더하기

https://school.programmers.co.kr/learn/courses/30/lessons/76501 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 class Solution { public int solution(int[] absolutes, boolean[] signs) { int answer = 0; for (int i = 0; i < signs.length; i++) { if (!signs[i]) absolutes[i] = -absolutes[i]; answer += absolutes[i]; } return answer; } }

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 핸드폰 번호 가리기

https://school.programmers.co.kr/learn/courses/30/lessons/12948 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 class Solution { public String solution(String phone_number) { return "*".repeat(phone_number.length()-4) + phone_number.substring(phone_number.length()-4); } } 다른 풀이 class Solution { public String solution(String pho..

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 나누어 떨어지는 숫자 배열

https://school.programmers.co.kr/learn/courses/30/lessons/12910 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 import java.util.ArrayList; import java.util.Arrays; class Solution { public int[] solution(int[] arr, int divisor) { ArrayList answer = new ArrayList(); Arrays.sort(arr); for (int a : arr) { if (a % divisor == 0) ans..

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 서울에서 김서방 찾기

https://school.programmers.co.kr/learn/courses/30/lessons/12919 코딩테스트 연습 - 서울에서 김서방 찾기 String형 배열 seoul의 element중 "Kim"의 위치 x를 찾아, "김서방은 x에 있다"는 String을 반환하는 함수, solution을 완성하세요. seoul에 "Kim"은 오직 한 번만 나타나며 잘못된 값이 입력되는 경우는 없습니 school.programmers.co.kr 나의 풀이 class Solution { public String solution(String[] seoul) { String answer = ""; for (int i = 0; i < seoul.length; i++) { if (seoul[i].equals("K..

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 콜라츠 추측

https://school.programmers.co.kr/learn/courses/30/lessons/12943 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 class Solution { public int solution(long num) { if (num == 1) return 0; for (int i = 0; i < 500; i++) { if (num == 1){ return i; } if (num % 2 == 0) num /= 2; else num = num * 3 + 1; } return -1; } }

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 두 정수 사이의 합

https://school.programmers.co.kr/learn/courses/30/lessons/12912 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 class Solution { public long solution(int a, int b) { long answer = 0; if (a > b) { int tmp = a; a = b; b = tmp; } for (int i = a; i < b+1; i++) { answer += i; } return answer; } } 다른 풀이 class Solution { public long s..

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 하샤드 수

https://school.programmers.co.kr/learn/courses/30/lessons/12947 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 class Solution { public boolean solution(int x) { String[] str = String.valueOf(x).split(""); int sum = 0; for (String s : str) sum += Integer.parseInt(s); return x % sum == 0; } } 다른 풀이 class Solution { public boolea..

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 정수 내림차순으로 배치하기

https://school.programmers.co.kr/learn/courses/30/lessons/12933 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 import java.util.Arrays; class Solution { public long solution(long n) { StringBuilder sb = new StringBuilder(); char[] str = String.valueOf(n).toCharArray(); Arrays.sort(str); for (int i = str.length-1; i > -1; i--) ..

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 문자열을 정수로 바꾸기

https://school.programmers.co.kr/learn/courses/30/lessons/12925 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 class Solution { public int solution(String s) { if (s.charAt(0) == '+') s = s.replace("+", ""); return Integer.parseInt(s); } }

Coding Test/Programmers

[Java]프로그래머스 Lv. 1 정수 제곱근 판별

https://school.programmers.co.kr/learn/courses/30/lessons/12934 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 class Solution { public long solution(long n) { double sqrt = Math.sqrt(n); if(sqrt == (int) sqrt){ return (long)Math.pow(sqrt + 1, 2); } else return -1; } }

97Arty
'Coding Test' 카테고리의 글 목록 (2 Page)