일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- codility
- 클린코드
- 노마드코더
- BOJ
- 액티비티
- github
- androidstudio
- java
- 윈도우10
- 데이터바인딩
- Windows10
- 지하철api
- Node.js
- 북클럽
- 노개북
- 노마드북클럽
- RecyclerView
- CardView
- 트렐로 삭제
- 선형레이아웃
- 사용자폴더
- 백준
- Android
- 부스트캠프
- CS50
- 알고리즘
- listview
- activity
- 안드로이드
- 부스트코스
- 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/
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/uMcPy/btqugDJEjVW/u95gwcVhGFnSkkxI6Yh61k/img.png)
...더보기 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..