diff --git a/src/main/java/src/main/java/com/sorts/PigeonholeSort.java b/src/main/java/src/main/java/com/sorts/PigeonholeSort.java index 6b77050b..1f8b498b 100644 --- a/src/main/java/src/main/java/com/sorts/PigeonholeSort.java +++ b/src/main/java/src/main/java/com/sorts/PigeonholeSort.java @@ -17,20 +17,12 @@ public class PigeonholeSort { public Integer[] sort(Integer[] arr) { // Find maximum and minimum elements in array - int min = arr[0]; - int max = arr[0]; + int min = Integer.MAX_VALUE; + int max = Integer.MIN_VALUE; for (Integer integer : arr) { - - // For minimum value - if (min > integer) { - min = integer; - } - - // For maximum value - if (max < integer) { - max = integer; - } + min = Math.min(min, integer); + max = Math.max(max, integer); } // Range