3 ms·
> a. You can't iterate a 'String' backwards. You need to know the length first. And that requires traversing the string forwards at least once. That's not at a
by zbentley 8y ago
> a. You can't iterate a 'String' backwards. You need to know the length first. And that requires traversing the string forwards at least once.
That's not at all true in many languages. If a candidate asked "is this string's length known without an O(N) operation on the number of characters in it?" (or knew the answer for the default string constructs in the language they were using for the problem) I'd consider that a positive indicator. If they said what you just said, without consideration for the context, I'd consider that a negative.
This is not a case of someone expecting a given "cookie cutter" solution. Interviewers who do that are doing themselves and their candidates a disservice. This is a case where statements like "I know how strings work because I know how they work in $context" where $context is not what the interview expects you to work in will make a bad impression.
- kamaal 8y ago>> Interviewers who do that are doing themselves and their candidates a disservice. Bad news is people who work at FAANG companies think they are the best of the human race there has ever been. And you have to the give the answers they want.
- dang 8y agoPlease don't post like this here. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html