What strategy should I use to sovle this interview problem? May I apply DP on this?
This problem is NP-hard. The decision problem, whether a perfect allocation exists, it self is NP-hard. The decision variant is actually the same as the subset sums problem. Given a set of numbers $S$ and a target number $k$, is there a subset of $S$ that sum up to $k$. The problem itself is a variation of the Knapsack problem.

However, the subset sum problem and the knapsack problem are both weak NP-hard problem. Both admit pseudo polynomial dynamic programming solutions (polynomial in the values of the input). So here is a dynamic programming solution for your problem. For each $i \in \{0, \dots n\}$, let us define the function $dp_i : [M] \rightarrow {0, 1}$, where $M$ is the sum of all needs of drugs from all patients. Now set $dp_0(0) = 1$. And for each $i$, we compute $dp_i$ as $dp_i(k)$ equals to 1 if and only if there is a subset of the first $i$ patients that need exactly $k$ units. The transitions are as follows:
$$dp_i(s) = \max\{dp_{i-1}(s), dp_{i-1}(s) - \mathrm{need}(i)\}.$$

An efficient way to implement it is by using bitwise operations on bitsets (a standard trick), where $dp_i = dp_{i-1} | (dp_{i-1}&lt;&lt; \mathrm{need}(i))$, where $|$ is logical or-operator and the $&lt;&lt;$ is left-shifting.