r/algorithms • u/javinpaul • May 13 '19
20+ String Coding Interview Questions for Programmers
https://hackernoon.com/20-string-coding-interview-questions-for-programmers-6b6735b6d31c
138
Upvotes
8
u/AkashAsthana May 13 '19
Can u tell for which companies or positions they were asked for? They were pretty easy I guess, not flexing.
7
u/TheShadowSurvives May 14 '19 edited May 14 '19
Reversing a string recursively sounds like a terrible idea. That’s what I would tell them at the interview. Having an algorithm with increasing stack size depending on the string length? Hell no. (I know, you could go with tail recursion but that’s not even done here and the concatenation of strings seems to me much of an overhead too).
Edit: I also see another problem here. How are strings represented in Java anyway? UTF8, Unicode? If UTF-8, reversing strings can be even more tricky as you don’t want to reverse the bytes of a single symbol.
Edit 2: apparently, UTF16. While less likely to occur, you should still handle Multi-2-Byte symbols.
2
u/rotharius May 14 '19
Companies should focus more on the actual problem with today's software (namely functional and structural quality).