Therefore i’m trying to complete the projects with “clean” solutions, but since i don’t really actually know what makes some solutions better than others (apart from time complexity), i’d like some input on this one. I was really happy with it because it’s very short and readable, but i know that doesn’t necessarily mean GOOD code. I just thought this one was good because it doesn’t need as many comparisons and conditions as using the “number approach”
So here it is ,
I’d git rid of the double reverse, personally. Also, why make the thousands a special case? You can only go up to 3999 with traditional Roman numerals, so just use the same logic as above instead of making a special case.
Yeah i was thinking that the double reverse isn’t great. Also very good point, idk why i went for that with thousands, will get rid of it now. Thanks man.
EDIT : Although for the double reverse, it kinda forces me to either check the length of split or do some more operations with indexes in the logic ? Genuinely curious to know why double reverse wouldn’t be more efficient/readable in this case where we know the size of the obtained arrays to be minuscule.