MIXTURES - spoj

Question link: https://www.spoj.com/problems/MIXTURES
Answer: https://ide.codingblocks.com/s/48539

Please check it is giving null pointer exception

Hey @Vidushi04
Your approach to the question is not right.
A null pointer exception is thrown when an application attempts to use null in a case where an object is required. These include: Calling the instance method of a null object. Accessing or modifying the field of a null object.

I am sharing my code for your ease so that you get to the right direction.
https://ide.codingblocks.com/s/48723

I have included all the 3 approaches in the code namely, recursion, Top-down DP and Bottom-Up DP. This would help you in learning and revising the concepts very well. Take help from it and then try to code it yourself.

Hope it helps! :relaxed:

Thank you so much sir
Sir please tell me where I was calling the instance of null object.
There can be only one chance when base case is hit, so at base case I made the instance values either 0 or max

Try debugging your code using the debugger in Eclipse ide. That would also help you know and learn your mistake. Yes, the problem lies due to base case and when n is negative.
And learn the DP-dynamic programming approach for such questions. That is the best and most efficient approach.