Algorithm/Java

Algorithm/Java

프로그래머스 lv1 - 핸드폰 번호 가리기

https://school.programmers.co.kr/learn/courses/30/lessons/12948 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr https://howtodoinjava.com/java/string/get-last-4-characters/ Get Last 4 Chars of a String in Java - HowToDoInJava Learn how to get last 4 characters of a String or simply any number of last characters of a string in Java us..

Algorithm/Java

프로그래머스 lv1 - 하샤드 수

https://school.programmers.co.kr/learn/courses/30/lessons/12947 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr - 10으로 나눈 나머지를 활용, 모든 자릿수를 합한 후 그걸로 나눈 나머지가 0인지 판별 class Solution { public boolean solution(int x) { int numbers=0, temp=x; while(temp>0){ numbers+=temp%10; temp/=10; } return (x%numbers==0)?true: false; } }

Algorithm/Java

프로그래머스 lv1 - 정사각형 별찍기

https://school.programmers.co.kr/learn/courses/30/lessons/12969 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr- 이중 반복문 사용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;i

Algorithm/Java

프로그래머스 lv1 - x만큼 간격이 있는 n개의 숫자

https://school.programmers.co.kr/learn/courses/30/lessons/12954 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr -x의 배수를 x*n까지 출력한다고 생각하면 됨 -반복문 사용 -숫자가 커질 때를 고려해서, x의 데이터타입을 일시적으로 long으로 변환해주기! class Solution { public long[] solution(int x, int n) { long[] answer = new long[n]; for(int i=1; i

Algorithm/Java

프로그래머스 lv1 정수 제곱근 판별

https://school.programmers.co.kr/learn/courses/30/lessons/12934 class Solution { public long solution(long n) { long k=(long)Math.sqrt(n); if (n==k*k) return (k+1)*(k+1); else return -1; } }

Algorithm/Java

프로그래머스 - 비밀지도

https://school.programmers.co.kr/learn/courses/30/lessons/17681 class Solution { void toBinary(int n, int[] numbers, StringBuilder[] real){ for(int i=0;i0){ int temp = t%2; if (temp==1) real[i].setCharAt(fromBackIdx,'#'); t/=2; fromBackIdx--; } } } StringBuilder[] solution(int n, int[] arr1, int[] arr2) { StringBuilder[] answer = new StringBuilder[n]; for(int k=0;k

Algorithm/Java

프로그래머스 - 옹알이(2)

https://school.programmers.co.kr/learn/courses/30/lessons/133499#qna class Solution { public int solution(String[] babbling) { int answer = 0; String[] words = {"aya", "ye", "woo", "ma"}; for(int i=0;i0) { cycle = true; //일치하는 게 없이 한 사이클 다 돌았는지 체크 for (int idx = 0; idx < 4; idx++) { if (babbling[i].startsWith(words[idx])) { cycle = false; babbling[i] = babbling[i].replaceFirst(words[idx], ""); t..

Algorithm/Java

프로그래머스 - 위장

https://school.programmers.co.kr/learn/courses/30/lessons/42578 import java.util.*; class Solution { public int solution(String[][] clothes) { int answer = 1; Map closet = new HashMap(); for(int i=0;i

Algorithm/Java

프로그래머스 - 주차 요금 계산

https://school.programmers.co.kr/learn/courses/30/lessons/92341 import java.util.*; class Solution { Map carSumTime = new TreeMap(); //누적 시간 Map carIn = new HashMap(); //입차 시간 public void calTime(int carNum, String carOut){ String[] inTime = carIn.get(carNum).split(":"); String[] outTime = carOut.split(":"); int time = (Integer.parseInt(outTime[0])-Integer.parseInt(inTime[0]))*60 +Integer.parseI..

Algorithm/Java

프로그래머스 - 숫자의 표현

https://school.programmers.co.kr/learn/courses/30/lessons/12924?language=java class Solution { public int solution(int n) { int answer = 1; for(int i=1;i

yoursin
'Algorithm/Java' 카테고리의 글 목록 (10 Page)