First Digit
Given a non-negative integer n, return the first (most-significant) digit in its decimal representation. For n = 0, return 0.
Given a non-negative integer `n`, return the first (most-significant) digit in its decimal representation. For `n = 0`, return `0`.
- `0 <= n <= 10^9` - The input has no leading zeroes except for `0` itself.
Example 1: input n = 482731; output 4. Four is the most-significant digit.
Example 2: input n = 10000; output 1. Repeated division leaves one.
Category: Math. Topic: math. Difficulty: Easy. Patterns: math.