Round to X Significant Digits with Thousand Separators
Given a numeric string S and an integer X, return a string representation of S rounded to X significant digits, with thousand separators applied where applicable. If X truncates the integer portion, pad with trailing zeros.
Asked at:
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late March, 2026
Junior
You get a string S and a number X. You should return a string with only X many digits. If applicable, you should add thousand delimiters. If X truncates the integer portion, you should append 0's. Example: 1. 1900.24582, x = 5 → 1,900.2 2. 1.2538, x = 3 → 1.25 3. 13222.234, x = 3 → 13,200
Hello Interview Premium
Your account is free and you can post anonymously if you choose.