2019-05-20 글쓴이 TED HONG
[Hackerrank] Counting Valleys
게리가 계곡을 몇번이나 들어갔었는지 체크하는 문제
static int countingValleys(int n, string s)
{
int vallyCount = 0;
int att = 0;
int lastAtt = 0;
char[] steps = s.ToCharArray();
for (int i = 0; i < n; i++)
{
lastAtt = att;
if (steps[i] == 'U') att++;
else if (steps[i] == 'D') att--;
if (lastAtt < 1 && att == 0) vallyCount++;
}
return vallyCount;
}
'프로그래밍' 카테고리의 다른 글
[Hackerrank] Repeated String (0) | 2023.02.20 |
---|---|
[Hackerrank] Jumping On Cloud (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 |
[Unity3D] UGUI 아틀라스에서 Sprite 파일 분리하기 (0) | 2023.02.20 |