We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9fe55c8 commit 1274140Copy full SHA for 1274140
src/main/java/src/main/java/com/sorts/PigeonholeSort.java
@@ -17,20 +17,12 @@ public class PigeonholeSort {
17
public Integer[] sort(Integer[] arr) {
18
19
// Find maximum and minimum elements in array
20
- int min = arr[0];
21
- int max = arr[0];
+ int min = Integer.MAX_VALUE;
+ int max = Integer.MIN_VALUE;
22
23
for (Integer integer : arr) {
24
-
25
- // For minimum value
26
- if (min > integer) {
27
- min = integer;
28
- }
29
30
- // For maximum value
31
- if (max < integer) {
32
- max = integer;
33
+ min = Math.min(min, integer);
+ max = Math.max(max, integer);
34
}
35
36
// Range
0 commit comments