Coding questions are not language independent though. You might as well ask to write a monad transformer in a language of their choice.
def reverse_str(x):
return x[::-1]
works. If you remember this notation, then you'll have this problem done in 30 seconds or less. But even if you don't remember this notation, I expect a candidate to figure out some way to reverse a string within 5 minutes in some language. I can think of engineering roles that rarely work with strings, but in the roles I hire for, we use them a lot and so I want to know that you have the basics down. If you know that: * strings are simply arrays of chars
* how to access an item in an array
* how to write a for loop
Then you have the tools you need to solve this problem. Are there any common languages where this is a particularly difficult problem (I'm genuinely curious, not trying to be obnoxious... if so, then I might consider changing the question for the future)?One should be able to devise a solution to a simple problem like this without any CS course at all.
or code units/code points/grapheme clusters/emojis. Thanks to hard work of many developers string handling becomes easier over time, but I don't think it's trivial if you don't exactly specify what you mean by "string" and "character".
The human touch.