Skip to content

Instantly share code, notes, and snippets.

@halitanildonmez
Last active September 1, 2020 20:07
Show Gist options
  • Save halitanildonmez/999567a349f4663042a6adc08d951fb1 to your computer and use it in GitHub Desktop.
Save halitanildonmez/999567a349f4663042a6adc08d951fb1 to your computer and use it in GitHub Desktop.
Solution for Bike Tour challenge on 2020 Kickstart round B
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