I don't know that this exact implementation is a popular problem (restricting the user to these particular indices), but it's a version of the two-sum problem which is a well-known problem. I wouldn't really consider what you did cheating, by the way ;)
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I was asked this question in my own interview for my current job 5 years ago. I liked it so much I decided to make Katas from the memorable ones.
Where does it go thru the array twice?
After
.map
it's a join. Is that considered to be going thru the array?I am glad others are saying it was difficult too!! I totally underestimated it!
I don't know that this exact implementation is a popular problem (restricting the user to these particular indices), but it's a version of the two-sum problem which is a well-known problem. I wouldn't really consider what you did cheating, by the way ;)