일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- 반려동물
- 세팔로투스
- 실생묘
- Wall-E
- creative park
- 애완동물
- paper craft
- 끄니
- 아기고양이
- 세팔
- Blueberry
- ios
- UIAlertView addSubView
- 블루베리
- UIAlertView setFrame
- 명랑이
- cephalotus
- 산책묘
- objective-c
- 고양이
- 끈끈이주걱
- 식충식물
- 태그를 입력해 주세요.
- codility
- 고양이 산책
- paper-replika
- 종이모형
- 스파르탄
- PassingCars
- CountDiv
Archives
- Today
- Total
꼼시월드
[codility] Task name: PassingCars 본문
int solution(NSMutableArray *A) { // write your code in Objective-C 2.0 int east = 0, west = 0; for (NSNumber *num in A) { int dir = [num intValue]; (dir) ? west++ : east++; } int wc = 0; int ec = 0; int ret = 0; for (int i = 0 ; i < A.count; i++) { if ([A[i] intValue]) // 1, west { ret = ret + ec; } else // 0, east { ec++; } } if (ret > 1000000000) return -1; // if car pair exceeds 1000000000 else return ret; }
'iOS' 카테고리의 다른 글
[codility] Binary Gap (0) | 2023.02.22 |
---|---|
[codility] CountDiv (3) | 2015.06.10 |
UIAlertView addSubView ios7 (0) | 2014.01.29 |
중첩된 딕셔너리의 키를 이용하여 정렬하기 (0) | 2014.01.24 |
ios 기기의 회전 값 구하기 (0) | 2014.01.21 |
Comments