Last active
September 1, 2020 20:07
-
-
Save halitanildonmez/999567a349f4663042a6adc08d951fb1 to your computer and use it in GitHub Desktop.
Solution for Bike Tour challenge on 2020 Kickstart round B
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); | |
int T = sc.nextInt(); | |
for (int testCase = 1; testCase <= T; testCase++) { | |
int N = sc.nextInt(); | |
int [] houses = new int[N]; | |
for (int i = 0; i < N; i++) { | |
int ai = sc.nextInt(); | |
houses[i] = ai; | |
} | |
int peaks = 0; | |
for (int i = 1; i < N - 1; i++) { | |
int cur = houses[i]; | |
if (cur > houses[i-1] && cur > houses[i+1]) | |
peaks++; | |
} | |
System.out.println("Case #" + testCase + ": " + peaks); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment