전체 글

웹 개발 공부를 하고있습니다 ᕕ( ᐛ )ᕗ
프로그래머스/Lv.1

Lv.1 정수 제곱근 판별

https://programmers.co.kr/learn/courses/30/lessons/12934 코딩테스트 연습 - 정수 제곱근 판별 임의의 양의 정수 n에 대해, n이 어떤 양의 정수 x의 제곱인지 아닌지 판단하려 합니다. n이 양의 정수 x의 제곱이라면 x+1의 제곱을 리턴하고, n이 양의 정수 x의 제곱이 아니라면 -1을 리턴하는 함 programmers.co.kr 기본틀 class Solution { public long solution(long n) { long answer = 0; return answer; } } 첫번째 시도 class Solution { public double solution(long n) { double x = Math.sqrt(n); double a = x - (..

프로그래머스/Lv.1

Lv.1 제일 작은 수 제거하기

https://programmers.co.kr/learn/courses/30/lessons/12935 코딩테스트 연습 - 제일 작은 수 제거하기 정수를 저장한 배열, arr 에서 가장 작은 수를 제거한 배열을 리턴하는 함수, solution을 완성해주세요. 단, 리턴하려는 배열이 빈 배열인 경우엔 배열에 -1을 채워 리턴하세요. 예를들어 arr이 [4,3,2,1 programmers.co.kr 기본틀 class Solution { public int[] solution(int[] arr) { int[] answer = {}; return answer; } } 첫번째 시도 class Solution { public int[] solution(int[] arr) { if(arr.length == 1){ in..

프로그래머스/Lv.1

Lv.1 최대공약수와 최소공배수

https://programmers.co.kr/learn/courses/30/lessons/12940 코딩테스트 연습 - 최대공약수와 최소공배수 두 수를 입력받아 두 수의 최대공약수와 최소공배수를 반환하는 함수, solution을 완성해 보세요. 배열의 맨 앞에 최대공약수, 그다음 최소공배수를 넣어 반환하면 됩니다. 예를 들어 두 수 3, 12의 programmers.co.kr 기본틀 class Solution { public int[] solution(int n, int m) { int[] answer = {}; return answer; } } 첫번째 시도 class Solution { public int[] solution(int n, int m) { int gcd = 0, lcm = 0; int ..

프로그래머스/Lv.1

Lv.1 콜라츠 추측

https://programmers.co.kr/learn/courses/30/lessons/12943 코딩테스트 연습 - 콜라츠 추측 1937년 Collatz란 사람에 의해 제기된 이 추측은, 주어진 수가 1이 될때까지 다음 작업을 반복하면, 모든 수를 1로 만들 수 있다는 추측입니다. 작업은 다음과 같습니다. 1-1. 입력된 수가 짝수라면 2 programmers.co.kr 기본틀 class Solution { public int solution(int num) { int answer = 0; return answer; } } 첫번째 시도 class Solution { public int solution(int num) { int answer = 0; while(num != 1){ if(answer =..

프로그래머스/Lv.1

Lv.1 평균 구하기

https://programmers.co.kr/learn/courses/30/lessons/12944 코딩테스트 연습 - 평균 구하기 정수를 담고 있는 배열 arr의 평균값을 return하는 함수, solution을 완성해보세요. 제한사항 arr은 길이 1 이상, 100 이하인 배열입니다. arr의 원소는 -10,000 이상 10,000 이하인 정수입니다. 입출력 예 arr programmers.co.kr 기본틀 class Solution { public double solution(int[] arr) { double answer = 0; return answer; } } 첫번째 시도 class Solution { public double solution(int[] arr) { double answer ..

프로그래머스/Lv.1

Lv.1 하샤드 수

https://programmers.co.kr/learn/courses/30/lessons/12947 코딩테스트 연습 - 하샤드 수 양의 정수 x가 하샤드 수이려면 x의 자릿수의 합으로 x가 나누어져야 합니다. 예를 들어 18의 자릿수 합은 1+8=9이고, 18은 9로 나누어 떨어지므로 18은 하샤드 수입니다. 자연수 x를 입력받아 x가 하 programmers.co.kr 기본틀 class Solution { public boolean solution(int x) { boolean answer = true; return answer; } } 첫번째 시도 class Solution { public boolean solution(int x) { boolean answer = true; int sum = 0;..

프로그래머스/Lv.1

Lv.1 핸드폰 번호 가리기

https://programmers.co.kr/learn/courses/30/lessons/12948 코딩테스트 연습 - 핸드폰 번호 가리기 프로그래머스 모바일은 개인정보 보호를 위해 고지서를 보낼 때 고객들의 전화번호의 일부를 가립니다. 전화번호가 문자열 phone_number로 주어졌을 때, 전화번호의 뒷 4자리를 제외한 나머지 숫자 programmers.co.kr 기본틀 class Solution { public String solution(String phone_number) { String answer = ""; return answer; } } 첫번째 시도 class Solution { public String solution(String phone_number) { String answer ..

프로그래머스/Lv.1

Lv.1 행렬의 덧셈

https://programmers.co.kr/learn/courses/30/lessons/12950 코딩테스트 연습 - 행렬의 덧셈 행렬의 덧셈은 행과 열의 크기가 같은 두 행렬의 같은 행, 같은 열의 값을 서로 더한 결과가 됩니다. 2개의 행렬 arr1과 arr2를 입력받아, 행렬 덧셈의 결과를 반환하는 함수, solution을 완성해주세요 programmers.co.kr 기본틀 class Solution { public int[][] solution(int[][] arr1, int[][] arr2) { int[][] answer = {}; return answer; } } 첫번째 시도 class Solution { public int[][] solution(int[][] arr1, int[][] a..

프로그래머스/Lv.1

Lv.1 x만큼 간격이 있는 n개의 숫자

https://programmers.co.kr/learn/courses/30/lessons/12954 코딩테스트 연습 - x만큼 간격이 있는 n개의 숫자 함수 solution은 정수 x와 자연수 n을 입력 받아, x부터 시작해 x씩 증가하는 숫자를 n개 지니는 리스트를 리턴해야 합니다. 다음 제한 조건을 보고, 조건을 만족하는 함수, solution을 완성해주세요. programmers.co.kr 기본틀 class Solution { public long[] solution(int x, int n) { long[] answer = {}; return answer; } } 첫번째 시도 class Solution { public long[] solution(int x, int n) { long[] answe..

프로그래머스/Lv.1

Lv.1 직사각형 별찍기

https://programmers.co.kr/learn/courses/30/lessons/12969 코딩테스트 연습 - 직사각형 별찍기 이 문제에는 표준 입력으로 두 개의 정수 n과 m이 주어집니다. 별(*) 문자를 이용해 가로의 길이가 n, 세로의 길이가 m인 직사각형 형태를 출력해보세요. 제한 조건 n과 m은 각각 1000 이하인 자연수 programmers.co.kr 첫번째 시도 import java.util.Scanner; class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); for(int i = 0; ..

코딩하는토끼
TOKKI Library