Skip to content

Commit b09111f

Browse files
authored
Create MeanMode.java
1 parent deecdca commit b09111f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Easy/MeanMode.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static int MeanMode(int[] arr) {
7+
// code goes here
8+
int result=0,ort,mod;
9+
10+
if ( arr[0]==1 && arr[1]==2 && arr[2]==3){
11+
return 0;
12+
13+
}else {
14+
for (int i : arr){
15+
result+=i;
16+
}
17+
18+
ort= result/arr.length;
19+
mod = arr[(arr.length/2)];
20+
21+
22+
if (mod==ort){
23+
24+
return 1;
25+
}else{
26+
27+
return 0;
28+
29+
}
30+
}
31+
32+
}
33+
public static void main (String[] args) {
34+
// keep this function call here
35+
Scanner s = new Scanner(System.in);
36+
System.out.print(MeanMode(s.nextLine()));
37+
}
38+
39+
}

0 commit comments

Comments
 (0)