← 返回 akunacapital 的题目列表Min Mod and Max
类型:online_judge
Given an integer array, find the minimum modulus value and the maximum value in the array. The return value should be an array containing the minimum modulus value and the maximum value. The minimum modulus value is the smallest result of all elements modulo a constant K, and the maximum value is the largest element in the array.
Input
An array arr consisting of integers
An integer K
Output
An array containing two integers, where the first integer is the minimum modulus value and the second is the maximum value.
Example
Example 1:
Input: arr = [3, 5, 7, 9], K = 4
Output: [0, 9]
Example 2:
Input: arr = [10, 20, 30, 40], K = 3
Output: [1, 40]
Data Constraints
The length of the array n is such that 1 <= n <= 1000
The elements of the array and K satisfy 1 <= K <= 1000
Example
Input
3
3 5 7 9
4