Largest Digit
Return the largest decimal digit that appears in the non-negative integer n.
For example, 2734 is written with the digits 2, 7, 3 and 4, so the answer is 7. A number below 10 is its own answer, so n = 0 gives 0.
Example 1
n 2734
returns 7
The digits are 2, 7, 3 and 4; the largest is 7.
Example 2
n 5
returns 5
A single digit is its own largest digit.
Constraints
0 <= n <= 10**9
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Recursion problems
- Multiply It OutBeginner
- Nested SumBeginner
- Rising DigitsBeginner
- Ruler PatternBeginner
- Same Both WaysBeginner
- Suffix ChainBeginner
- Wheels in the RowBeginner
- Deep ReverseEasy