일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 노마드북클럽
- codility
- 안드로이드
- listview
- github
- java
- RecyclerView
- 액티비티
- androidstudio
- CardView
- 백준
- 클린코드
- 부스트캠프
- 부스트코스
- 사용자폴더
- 노개북
- Node.js
- 지하철api
- Android
- 윈도우10
- 북클럽
- 트렐로 삭제
- activity
- BOJ
- 노마드코더
- 데이터바인딩
- 선형레이아웃
- CS50
- Windows10
- 알고리즘
- Today
- Total
목록Algorithm (8)
Be Developer
문제요약 나선 모양으로 놓여지는 N번째 정삼각형 변의 길이를 구하시오. 풀이 P(1) = P(2) = P(3) = 1 P(4) = P(5) = 2 P(6)부터 P(N) = P(N-5) + P(N-1) 다른 사람의 풀이를 보니, P(4)부터 P(N) = P(N-3) + P(N-2)로 풀이 할 수 있었다. 코드 시간 복잡도 O(N) import java.util.Scanner; public class BOJ_9461 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); for (int i=0; i
문제요약 만들 수 있는 (0, 1) 쌍의 개수를 구하시오. 풀이 배열을 순회하면서 0의 개수를 누적해서 더하고, 1을 만나면 누적된 0의 개수를 더한다. 코드 시간복잡도 O(N) public static int solution(int[] A) { int pairs = 0; int count_zero = 0; for (int n : A) { if (n == 0) { count_zero++; } else if (n == 1) { pairs += count_zero; } if (pairs > 1000000000) { return -1; } } return pairs; } 출처 : https://app.codility.com/programmers/lessons/5-prefix_sums/passing_cars/
문제요약 00과 1로 만들 수 있는 2진 수열의 개수를 구하시오. 풀이 N=1일 때, [1] - 1개 N=2일 때, [00, 11] - 2개 N=3일 때, [001, 100, 111] - 3개 N=4일 때, [0000, 0011, 1001, 1100, 1111] - 5개 N=5일 때, [00001, 00100, 10000, 00111, 10011, 11001, 11100, 11111] - 8개 즉, N[i] = N[i-1] + N[i-2] 피보나치 수열로 풀 수 있다. 코드 import java.util.Scanner; public class BOJ_1904 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); ..

...더보기 A small frog wants to get to the other side of a river. The frog is initially located on one bank of the river (position 0) and wants to get to the opposite bank (position X+1). Leaves fall from a tree onto the surface of the river. You are given an array A consisting of N integers representing the falling leaves. A[K] represents the position where one leaf falls at time K, measured in se..