일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- 0으로 채우기
- 백준 16935
- sort
- java 내림
- Arrays
- java
- java 반올림
- 알고리즘
- 백준 14391
- Algorithm
- Codility
- 백준 11723
- Math.ceil()
- 프로그래머스 옹알이 java
- 코딩테스트
- 백준 18290
- 백준 17425
- 네트워크
- 프로그래머스 네트워크 java
- 백준 4375
- Math.floor()
- 백준 15661
- 프로그래머스 연속된 수의 합 java
- mysql
- 백준 16927
- 프로그래머스 도둑질 java
- time complexity
- java 올림
- 자바
- 프로그래머스 숫자의 표현 java
- Today
- Total
목록코딩테스트 (5)
취미처럼
1부터 N개의 서로 다른 정수로 이루어진 배열에서 누락된 하나의 요소 찾기 import java.util.Arrays; class Solution { public int solution(int[] A) { Arrays.sort(A); for (int i = 0; i < A.length; i++) { if (i + 1 != A[i]) { return i + 1; } } return A.length + 1; } }
고정값 D만큼 이동하여 X에서 Y까지 도달할 수 있는 최소 수행값 public int solution(int X, int Y, int D) { int distance = Y - X; return distance % D == 0 ? distance / D : distance / D + 1; }
배열 중 같은 수로써 짝이 맞지 않는 요소를 구하는 문제 public int solution(int[] A) { int answer = 0; for (int i = 0; i < A.length; i++) { answer ^= A[i]; } return answer; } XOR 연산은 같은 수일 때 0을 리턴한다.
주어진 배열 A에서 정수 K만큼 배열의 차수를 올리되, 차수가 배열 길이 이상일 때 0부터 다시 시작한다. public static int[] solution(int[] A, int K) { int answer[] = new int[A.length]; for (int i = 0; i < A.length; i++) { answer[(i + K) % A.length] = A[i]; } return answer; } int[] A = {0,3,4,2,5}; int K = 3; answer 배열의 인덱스 (0 + 3) % 5 = 3 answer[3] = A[0]; (1 + 3) % 5 = 4 answer[4] = A[1]; (2 + 3) % 5 = 0 answer[0] = A[2]; (3 + 3) % 5 = 1..
2진수의 1과 1사이의 간격 중 가장 큰 값을 찾는 문제 public static int solution(int N) { String str = Integer.toBinaryString(N); String[] arr = str.split(""); int totalGapLength = 0; int gapLength = 0; for (int i = 0; i totalGapLength) { totalGapLength = gapLength; } gapLength = 0; } else if(arr[i].equals("0")) { gapLength++; } } return totalGapLength; }