Sum ticket digits
An audit script fingerprints ticket IDs by summing the digit characters they contain. Given a string that may mix letters, digits, and punctuation, return the sum of all digit characters as a number. Return 0 if there are no digits. For example, 'ord-42x9' contains 4, 2, and 9, so the answer is 15.
Implement
digit_sum(s: str) → intExamples
in
["ord-42x9"]out15What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 10 min
solution.py
InputExpectedGot
["ord-42x9"]15not run yetsample