-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecord.java
48 lines (45 loc) · 1.17 KB
/
Record.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Record {
static int[] getRecord(int[] s ,int n){
// Complete this function
int high=0,low=0,h=0,l=0;
high=s[0];
low=s[0];
for(int i=0;i <n-1;i++)
{
if(s[i] <s[i+1])
{
high=s[i+1];
h++;
}
if(s[i] > s[i+1])
{
low=s[i+1];
l++;
}
}
int res[] = new int[2];
res[0]=h;
res[1]=l;
return res;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] s = new int[n];
for(int s_i=0; s_i < n; s_i++){
s[s_i] = in.nextInt();// taking imput..
}
int[] result = getRecord(s, n);
String separator = "", delimiter = " ";
for (Integer val : result) {
System.out.print(separator + val);
separator = delimiter;
}
System.out.println("");
}
}