about | help | code help+videos | done | prefs |
Write a method that accepts an array of any integers. If the array is empty, or only contains one element, return zero. Otherwise, return the minimum positive difference between ANY two pairs of integers in the array. For example, using the array {1242, -4324, 0, 124, 24, -124129, 118, 62, -142} the method would return 6 since the positive difference between 124 and 118 is 6 and there are no pairs in the array with a smaller positive difference. If the same number appears two or more times in the array, the smallest positive difference will be zero (since the difference between a number and itself is zero). Look at the test data for further examples. While this MAY be solved using back-track recursion, you are NOT required to do it that way! minimumDifferenceOffice([]) → 0 minimumDifferenceOffice([4]) → 0 minimumDifferenceOffice([5, 12]) → 7 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy