일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 북클럽
- 부스트캠프
- java
- 부스트코스
- 선형레이아웃
- 노마드북클럽
- 알고리즘
- 데이터바인딩
- 윈도우10
- 안드로이드
- codility
- 백준
- 노마드코더
- RecyclerView
- listview
- androidstudio
- 지하철api
- 트렐로 삭제
- CardView
- BOJ
- CS50
- 클린코드
- activity
- Android
- 사용자폴더
- 액티비티
- github
- Windows10
- Node.js
- 노개북
- Today
- Total
목록codility (2)
Be Developer
문제요약 만들 수 있는 (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/

...더보기 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..