ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Largest Digit

Find the largest decimal digit of a positive integer.

Look at every decimal digit of n and return the largest one.

Implement largest_digit(n).

Input

n: A positive integer.

Output

Return the largest digit, from 0 to 9.

เงื่อนไข

1 ≤ n ≤ 10¹⁸

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
n = 352

ผลลัพธ์ที่คาดหวัง:
expected = 5
อินพุต:
long long n = 352;

ผลลัพธ์ที่คาดหวัง:
long long expected = 5;
อินพุต:
long n = 352;

ผลลัพธ์ที่คาดหวัง:
long expected = 5;

คำอธิบาย

The digits are 3, 5 and 2; the largest is 5.

ตัวอย่างที่ 2
อินพุต:
n = 7

ผลลัพธ์ที่คาดหวัง:
expected = 7
อินพุต:
long long n = 7;

ผลลัพธ์ที่คาดหวัง:
long long expected = 7;
อินพุต:
long n = 7;

ผลลัพธ์ที่คาดหวัง:
long expected = 7;

คำอธิบาย

The only digit is 7.

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก