Code RoomSum ticket digits
EasyPrep Room Coding #595

Sum ticket digits

CodingAlgorithms & data structuresEntry–Mid~10 min

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) → int
Examples
in["ord-42x9"]out15
What 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
InputExpectedGot
["ord-42x9"]15not run yetsample