Is there any explaination for DP solution for this problem
@janmejaysingh74024 жыл бұрын
Nice explanation. Watched it again after one month and it is even more clear, I have only one question. Why this problem is classified in DP in leetcode?
@happycoding10934 жыл бұрын
because this problem can also be solved by using DP + bit mask. I just wrote the solution here: @lru_cache(None) def dp(k, mask, remain): if k == 0: return True ans = False for i in range(n): if mask & (1
@RAHULRAJ-rv4ng2 жыл бұрын
@@happycoding1093 Hi, Where have you done the memoization ? You have just used the name of functon as DP.
@learner_12283 жыл бұрын
what is the time complexity of the this solution?
@happycoding10933 жыл бұрын
O(k^(N-k)*k!)
@learner_12283 жыл бұрын
@@happycoding1093 Could you explain it how? Shouldn't it be O((2^n)*k)? since we will include a particular/current element or not,therefore 2 choices for every element, we will do it for k times. Is this correct?