Sum of First and Last Digits
Given a non-negative integer n, return the sum of its first (most-significant) and last (least-significant) decimal digits. If n has one digit, that digit is…
Given a non-negative integer `n`, return the sum of its first (most-significant) and last (least-significant) decimal digits. If `n` has one digit, that digit is both first and last, so add it to itself. Thus `0` returns `0`.
- `0 <= n <= 10^9` - The input has no leading zeroes except for `0` itself.
Example 1: input n = 482731; output 5. The boundary digits are 4 and 1.
Example 2: input n = 7; output 14. Seven is both the first and last digit.
Category: Math. Topic: math. Difficulty: Easy. Patterns: math.