2019-05-20 글쓴이 TED HONG
[Hackerrank] Jumping On Cloud
한 번에 최대 두칸 이동 가능
상태값이 1인 좌표로는 이동 불가
총 몇회 점프를 했는지 구하는 문제
static int jumpingOnClouds(int[] c)
{
int jumpCount = 0;
int num = 0;
int jumpPower = 2;
for (int i = 0; i < c.Length; i++)
{
jumpPower--;
if(jumpPower == 0 || (jumpPower == 1 && c[i] == 1))
{
jumpPower = 2;
jumpCount++;
}
}
return jumpCount;
}
'프로그래밍' 카테고리의 다른 글
[Hackerrank] 2D Array – DS (0) | 2023.02.20 |
---|---|
[Hackerrank] Repeated String (0) | 2023.02.20 |
[Hackerrank] Counting Valleys (0) | 2023.02.20 |
[UNITY] This application does not support this device’s CPU type. (0) | 2023.02.20 |
[Unity] Application.systemLanguage -> ISO 639-1 변환 (0) | 2023.02.20 |