Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>You work from the 1 position back to the front of the string.

You can work from the front of the string to the end and multiply your accumulated result by 10 at each step, can't you?

I might just be misunderstanding your wording, in which case ignore me.



I think that might work. My method makes more sense to me but that's because it's just the first thing that came to mind when thinking about the problem.

Your method means you only need to walk the string once which is better. Either way 9/10 interview candidates can't even get that far.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: