Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Create 2742-painting-the-walls.js#3979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
aadil42 wants to merge1 commit intoneetcode-gh:main
base:main
Choose a base branch
Loading
fromaadil42:patch-751968

Conversation

aadil42
Copy link
Contributor

Solved painting-the-walls

File(s) Added: 2742-painting-the-walls.js
Language(s) Used: JavaScript
Submission URL :https://leetcode.com/problems/painting-the-walls/submissions/1590922459/

Solved painting-the-walls
@@ -0,0 +1,27 @@
/**
* DP | Memoization
* Time O(n^2) | Space O(n^2)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can optimize space

/** * DP - Bottom Up * Array - Tabulation * Time O(N^2) | Space O(N) *@param {number[]} cost *@param {number[]} time *@return {number} */varpaintWalls=(cost,time)=>{consttabu=initTabu(cost);for(leti=0;(i<cost.length);i++){for(letremain=cost.length;(0<remain);remain--){constleft=tabu[Math.max(((remain-1)-time[i]),0)]+cost[i];constright=tabu[remain];tabu[remain]=Math.min(left,right);}}returntabu[cost.length];}varinitTabu=({ length})=>{consttabu=newArray(length+1).fill(Number.MAX_SAFE_INTEGER);tabu[0]=0;returntabu;}

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

@aakhtar3aakhtar3aakhtar3 left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@aadil42@aakhtar3

[8]ページ先頭

©2009-2025 Movatter.jp