Katkat

Round numeric string values

PinterestSoftware Engineer · Technical Screen

Last updated

This question evaluates parsing and numeric manipulation skills, specifically implementing rounding rules for numeric strings and handling decimals, significant digits, and precision edge cases.

Question

Given a numeric string, implement rounding to the nearest integer (e.g., '3.5' → '4', '100.01' → '100'). Follow-up: round to the last significant digit (e.g., 124900 → 125000, 12.49 → 12. 5).