-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHighestAndLowest.java
More file actions
36 lines (30 loc) · 861 Bytes
/
HighestAndLowest.java
File metadata and controls
36 lines (30 loc) · 861 Bytes
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
package com.smlnskgmail.jaman.codewarsjava.kyu7;
import java.util.Arrays;
// https://www.codewars.com/kata/554b4ac871d6813a03000035
public class HighestAndLowest {
private final String input;
public HighestAndLowest(String input) {
this.input = input;
}
public String solution() {
int[] parsedNumber = Arrays
.stream(input.split(" "))
.mapToInt(Integer::valueOf)
.toArray();
int minimum = Integer.MAX_VALUE;
int maximum = Integer.MIN_VALUE;
for (int i : parsedNumber) {
if (minimum > i) {
minimum = i;
}
if (i > maximum) {
maximum = i;
}
}
return String.format(
"%d %d",
maximum,
minimum
);
}
}