Re:LINQ Ruined My Favorite Interview Question
by kragen on Friday July 12, 2013 @03:09AM
(#6031310)
Not bad. I think it would be a little simpler and faster with:
But maybe there's a downside to that approach that isn't obvious to me?
[ Parent
| on HN ]
Re:LINQ Ruined My Favorite Interview Question
by navinp1912 on Friday July 12, 2013 @07:40AM
(#6032057)
If you move what while (topK--) into the map loop , it becomes an online code for topK whereas what you wrote is an offline . If you want offline then pushing it into a priority_queue and then popping it out would be much faster.