bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 2585. Number of Ways to Earn Points

2585. Number of Ways to Earn Points

Leetcode Solutions

Dynamic Programming - Bottom-Up Approach

  1. Initialize a one-dimensional array dp of size target + 1 with all elements set to 0 except dp[0] which is set to 1.
  2. Iterate over each type in types array.
  3. For each type, iterate over the dp array from target down to 0.
  4. For each value i in the dp array, iterate from the question's mark value v up to count * marks (where count is the number of questions of that type and marks is the mark value of that type), updating dp[i] by adding dp[i - v] to it.
  5. After processing all types, return dp[target] as the result.
UML Thumbnail

Dynamic Programming with Memoization

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...