Skip to content

Probem1 and Problem2 added#1797

Open
megharaykar wants to merge 1 commit into
super30admin:masterfrom
megharaykar:master
Open

Probem1 and Problem2 added#1797
megharaykar wants to merge 1 commit into
super30admin:masterfrom
megharaykar:master

Conversation

@megharaykar
Copy link
Copy Markdown

No description provided.

@super30admin
Copy link
Copy Markdown
Owner

Paint House (Problem1.py)

You have shown a good progression from recursive to dynamic programming solutions. However, there are a few points to improve:

  1. Avoid using global variables (like minimum) in recursive solutions because they can cause issues if the function is called multiple times. Instead, use a recursive function that returns the value, as in your second solution.

  2. Your third solution (with the for loop) is incorrect because the global minimum is not reset and the recursive calls do not return the correct value. To generalize for k colors, you should use a recursive function that returns the minimum cost without global state, or use DP.

  3. For the problem constraints (n up to 100), the recursive solutions with exponential time are not feasible. You should use dynamic programming, which you have implemented correctly in the later solutions.

  4. For Leetcode submissions, you should only provide one solution per class. The test code should be removed.

  5. Your DP solutions are excellent. The last solution with variables (costR, costB, costG) is optimal in both time and space.

Overall, you have a good understanding of the problem and have implemented efficient solutions. However, the recursive solutions need to be improved to avoid global state and to handle constraints.

VERDICT: NEEDS_IMPROVEMENT


Coin Change II (Problem2.py)

Note: The student has provided multiple solutions. Evaluate each one and then provide an overall verdict.

Let's begin.

VERDICT: NEEDS_IMPROVEMENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants