Solve binary-search knapsack & graph shortest path
MicrosoftSoftware Engineer · Online AssessmentLast updated
This question evaluates a candidate's ability to apply algorithmic optimization by using binary search instead of dynamic programming for a knapsack-style selection problem and to construct and compute shortest paths on a weighted graph from custom input.
Question
Given a sorted list of items, design an efficient solution (using binary search) to achieve the target objective instead of a dynamic-programming knapsack approach. Given a weighted graph provided in a custom input format, build the graph and compute the shortest path between two nodes.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.