JAVA_LeetCode 164_Maximum Gap 풀이 class Solution { public int maximumGap(int[] nums) { if(nums.length < 2) return 0; // 2개 미만이면 gap이 존재할 수 없음 // 전체 원소에서 최소, 최대값 찾기 int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; for(int num : nums){ min = Math.min(min, num); max = Math.max(max, num); } if(min == max) return 0; // 배열에 커버하는 범위(최대 - 최소 값에서 개수만큼 나눠진 몫) int gap = (int) Math.ceil((double)(max - min) / (nums.length - 1)), size = nums.length - 1; // 각 구간 내 두 연속된 요소의 최소, 최대값 저장 int[] arrMin = new in...
원문 링크 : JAVA_LeetCode 164_Maximum Gap