일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 끈끈이주걱
- codility
- 스파르탄
- 태그를 입력해 주세요.
- CountDiv
- 고양이
- PassingCars
- 실생묘
- 블루베리
- 끄니
- 애완동물
- 명랑이
- creative park
- 반려동물
- Wall-E
- Blueberry
- 세팔
- paper-replika
- paper craft
- ios
- UIAlertView setFrame
- 세팔로투스
- UIAlertView addSubView
- objective-c
- 식충식물
- cephalotus
- 산책묘
- 아기고양이
- 고양이 산책
- 종이모형
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