970. Maximum and Minimum Digit in a Number

Given a non-negative integer N, return an array of two integers, where:

  • The first element is the smallest digit in the number.
  • The second element is the largest digit in the number.

Example 1:

Input: 2746

Output: [2, 7]

Example 2:

Input: 23004

Output: [0, 4]

Now Your Turn!

Pick the correct output for the given input

Input: 5

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 0 ≤ N ≤ 1018
0
class Solution {
public:
vector<int> minMaxDigits(long long N) {
// Your code goes here
}
};
 
Test Case

Input:

N