Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
prasadhonrao committed Jun 7, 2019
2 parents c7581c9 + 126b135 commit 04fb4e2
Showing 1 changed file with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution {

// Complete the breakingRecords function below.
static int[] breakingRecords(int[] scores) {
int min = scores[0];
int max = scores[0];
int c1 = 0;
int c2 = 0;
for (int i = 0; i < n; i++)
{
if (scores[i] > max) {
c1+=1;
max=scores[i];
}
if (scores[i] < min) {
c2+=1;
min=scores[i];
}
}
return new int[] {c1, c2};
}

private static final Scanner scanner = new Scanner(System.in);

public static void main(String[] args) throws IOException {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));

int n = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

int[] scores = new int[n];

String[] scoresItems = scanner.nextLine().split(" ");
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

for (int i = 0; i < n; i++) {
int scoresItem = Integer.parseInt(scoresItems[i]);
scores[i] = scoresItem;
}

int[] result = breakingRecords(scores);

for (int i = 0; i < result.length; i++) {
bufferedWriter.write(String.valueOf(result[i]));

if (i != result.length - 1) {
bufferedWriter.write(" ");
}
}

bufferedWriter.newLine();

bufferedWriter.close();

scanner.close();
}
}

0 comments on commit 04fb4e2

Please sign in to comment.