programmers lv1
[프로그래머스, 12934] 정수 제곱근 판별 (java)
https://school.programmers.co.kr/learn/courses/30/lessons/12934 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr메모리: 73.8 MB, 시간: 0.06 ms사용 알고리즘: 수학 class Solution { public long solution(long n) { // n에 대한 루트 계산 long x = (long)Math.sqrt(n); // 다시 제곱 long tmp = (long)Math.pow(x, 2); ..
[프로그래머스, 12933] 정수 내림차순으로 배치하기 (java)
https://school.programmers.co.kr/learn/courses/30/lessons/12933 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr메모리: 78.4 MB, 시간: 0.03 ms사용 알고리즘: 구현class Solution { public long solution(long n) { int[] count = new int[10]; // 인덱스에 해당하는 수가 몇 개인지 저장 while(n > 0) { count[(int)(n % 10)]++; n /=..
[프로그래머스, 12932] 자연수 뒤집어 배열로 만들기 (java)
https://school.programmers.co.kr/learn/courses/30/lessons/12932 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr메모리: 74.5 MB, 시간: 0.04 ms사용 알고리즘: 구현import java.util.*;class Solution { public int[] solution(long n) { ArrayList list = new ArrayList(); // 맨 뒷자리부터 차례로 list에 넣기 while(n > 0) { ..
[프로그래머스, 12931] 자릿수 더하기 (java)
https://school.programmers.co.kr/learn/courses/30/lessons/12931 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr메모리: 77.3 MB, 시간: 0.03 ms사용 알고리즘: 문자열import java.util.*;public class Solution { public int solution(int n) { int answer = 0; while(n > 0) { answer += n % 10; n /= 10; } retu..
[프로그래머스, 12954] x만큼 간격이 있는 n개의 숫자 (java)
https://school.programmers.co.kr/learn/courses/30/lessons/12954 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr메모리: 73.6 MB, 시간: 0.05 ms사용 알고리즘: 구현class Solution { public long[] solution(int x, int n) { long[] answer = new long[n]; answer[0] = x; for(int i = 1; i
[프로그래머스, 12925] 문자열을 정수로 바꾸기 (java)
https://school.programmers.co.kr/learn/courses/30/lessons/12925 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr메모리: 77.2 MB, 시간: 0.04 ms사용 알고리즘: 문자열 Integer 메소드 사용class Solution { public int solution(String s) { return Integer.parseInt(s); }}직접 구현class Solution { public int solution(String s) { int answer..
[프로그래머스, 12916] 문자열 내 p와 y의 개수 (java)
https://school.programmers.co.kr/learn/courses/30/lessons/12916 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr메모리: 79.8 MB, 시간: 0.05 ms사용 알고리즘: 구현class Solution { boolean solution(String s) { boolean answer = true; char[] arr = s.toCharArray(); int p = 0, y = 0; for(int i = 0; i
[프로그래머스, 87389] 나머지가 1이 되는 수 찾기 (java)
https://school.programmers.co.kr/learn/courses/30/lessons/87389?language=java 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr메모리: 79.6 MB, 시간: 4.07 ms사용 알고리즘: 구현class Solution { public int solution(int n) { int answer = 1; while(n % answer != 1) answer++; return answer; }}
[프로그래머스, 132201] 12세 이하인 여자 환자 목록 출력하기 (mysql)
https://school.programmers.co.kr/learn/courses/30/lessons/132201 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr SELECT pt_name, pt_no, gend_cd, age, CASE WHEN tlno IS NULL THEN 'NONE' ELSE tlno END as tlno FROM patient WHERE age
[프로그래머스, 133024] 인기있는 아이스크림 (mysql)
https://school.programmers.co.kr/learn/courses/30/lessons/133024 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr SELECT flavor FROM first_half ORDER BY total_order desc, shipment_id