957. Return the Largest Digit in a Number
You are given an integer n. Return the largest digit present in the number.
Example 1:
Input: n = 25
Output: 5
Explanation: The largest digit in 25 is 5.
Example 2:
Input: n = 99
Output: 9
Explanation: The largest digit in 99 is 9.
Now Your Turn!
Pick the correct output for the given inputInput: n = 1
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 <= 5000
- n will contain no leading zeroes except when it is 0 itself.