Microsoft Fulltime SDE Online Test: Challenging DP Problems
Question Details
The following content requires a score higher than 188. You can already view it. A 105-minute lesson from Hacker's class, two questions in total: Question 1: [Unclear text - possibly a question number
Full Details
The following content requires a score higher than 188. You can already view it. A 105-minute lesson from Hacker's class, two questions in total: Question 1: [Unclear text - possibly a question number] Question 2: Given two arrays arr1 and arr2 of length n, you need to select k elements from them. Let r be the smaller of the sum of the selected elements in arr1 and the sum of the selected elements in arr2. Find the largest r. For example, arr1=[6,3,6,5,1], arr2=[1,4,5,9,2], k = 3. Then, selecting the position (0,2,3), its r = min(6+6+5, 1+5+9)=15. I solved it using knapsack dynamic programming. The general idea is: define dp[i][j] as the maximum sum of arr2 when i positions are selected and the sum of arr1 is j. Then I used the knapsack approach. It seems like the person with the "chrysanthemum addiction" (a term used to describe someone addicted to certain types of programming) really enjoys working on hard or dynamic programming problems. I didn't expect both of these to be dynamic programming problems (root swapping + knapsack problem), it's exhausting. Hopefully, my upcoming interviews will go smoothly. By the way, could you please give me some points? Thanks everyone. And best of luck with your interviews too!
About This Question
This is a reported interview question from a microsoft interview for a swe role during the oa round reported in 2025.
It covers the following topics: Arrays, Sql, Dynamic Programming, Dynamic Programming .
Difficulty rating: Hard