본문 바로가기

728x90

프로그래머스

나누어 떨어지는 숫자 배열 import java.util.Vector; import java.util.Arrays; class Solution { public Object[] solution(int[] arr, int divisor) { Vectorv = new Vector(); for(int i=0;i factor % divisor == 0).toArray(); } // 아래는 테스트로 출력해 보기 위한 코드입니다. public static void main(String[] args) { Divisible div = new Divisible(); int[] array = {5, 9, 7, 10}; System.out.println( Arrays.toString( div.divisible(array, 5) )); } } 람다식으로.. 더보기
하샤드수 class Solution { public boolean solution(int x) { boolean answer = true; String num =""; num = Integer.toString(x); int sum =0; for(int i=0;i 더보기
없는숫자더하기 class Solution { public int solution(int[] numbers) { int answer = 0; int[] numflag = new int[10]; for(int i=0;i 더보기
문자열 다루기 기본 나의코드 class Solution { public boolean solution(String s) { boolean answer = true; if(s.length() !=4 && s.length() !=6) return false; else { for(int i=0;i 더보기
두 정수 사이의 합 나의코드 class Solution { public long solution(int a, int b) { long answer = 0; long maxVal = b; int temp =0; if(maxVal 더보기
x만큼 간격이 있는 n개의 숫자 나의풀이 class Solution { public long[] solution(int x, int n) { long[] answer = new long[n]; long val=x; for(int i=0;i 더보기
핸드폰번호가리기 나의풀이 class Solution { public String solution(String phone_number) { String answer = ""; int starlength = phone_number.length()-4; for(int i=0;i 더보기
1차 비밀지도 카카오 static public String[] solution(int n, int[] arr1, int[] arr2) { String[] answer = new String[n]; String[] map1 = new String[n]; String[] map2 = new String[n]; for (int i = 0; i < arr1.length; i++) { map1[i] = Integer.toBinaryString(arr1[i]); map2[i] = Integer.toBinaryString(arr2[i]); while(map1[i].length() 더보기

728x90