It’s got some code duplication. Who can code
gulfgolf this?public static int convertRomanNumeral(String numeral) { return 4; // todo }Code gulf, you say?
public static String convertRomanNumeral(String numeral) { numeral = numeral.replace("America", "Mexico"); return numeral; }
Still linear time at least, could always be much MUCH worse
There could be a hidden quadratic cost because the string needs to be reallocated and copied multiple times.
Not if I don’t see it.
True. Lost opportunity to blow things up with useless recursivity
The word you’re looking for is recursion (see recursion).
Nah, I’d like to un-see recursion. It was way overblown on uni, I barely ever use it.
Recursion is amazing for a small selection of problems. Most of the time you don’t need, or want, it. When it is useful though, it tends to be really useful.
I don’t understand people’s issue with it. I always found it easy. Maybe that’s why I feel this way. Maybe if you find it challenging you want to avoid it, even when it’s a good solution.
Most devs I know like recursion. Trouble is that many popular languages don’t support tail recursion, but throw a stackoverflow error after a few thousand levels. So you have to keep track of max recursion depth manually, and it starts to look like a complicated solution
You mean, like this?






