dev-resources.site
for different kinds of informations.
Maximum Multiplication Score
Published at
10/3/2024
Categories
dp
leetcode
contest
Author
prashantrmishra
Author
15 person written this
prashantrmishra
open
Problem
TC: O(4*m) = O(m)
SC: O(4*m) = O(m) ( dp array) + O(4+m) for recursive stack space
class Solution {
public long maxScore(int[] a, int[] b) {
long dp[][] = new long[a.length][b.length];
for(long d[] : dp) Arrays.fill(d,-1);
return max(0,0,a,b,dp);
}
public long max(int i, int j, int a[], int b[],long dp[][]){
//base case
if(i ==a.length) return 0;
if(j ==b.length) return Long.MIN_VALUE/2;
if(dp[i][j]!=-1) return dp[i][j];
long take = (long)a[i]*b[j] + max(i+1,j+1,a,b,dp);
long dontTake = (long) max(i,j+1,a,b,dp);
return dp[i][j] = Math.max(take,dontTake);
}
}
contest Article's
30 articles in total
Minimum Division Operations to Make Array Non Decreasing
read article
Count Substrings With K-Frequency Characters I
read article
Cybersecurity Quiz Alert!
read article
Maximum Possible Number by Binary Concatenation
read article
Maximum Multiplication Score
currently reading
Find the Sequence of Strings Appeared on the Screen
read article
Remove Methods from project
read article
count-of-substrings-containing-every-vowel-and-k-consonants-i
read article
Participate in the SecureChain AI Thread Contest for a Chance to Win
read article
India DevOps League 2024
read article
প্রোগ্রামিং প্রতিযোগিতার নানান ধরন ।
read article
🎉 iPhone 15 Pro Max Giveaway! 🎉
read article
The brand new gaming contest is here, introducing the #GlobalGamers Challenge to build games with Flutter!
read article
Announcing the Brainstory Holiday Giveaway Contest: Unleash Your Creativity and Win Big! 🧠🎁
read article
Join the MiniScript "Advent of Code" contest!
read article
Announcing the Directus Panel Quest Hackathon
read article
InterSystems Python Programming Contest 2023
read article
🏆 Contest - Kintone Customization Contest 2023
read article
Hi DEV fellows 🥳❗
read article
I made a programming animation; guess the language to win art!
read article
InterSystems Developer Tools Contest
read article
InterSystems IRIS for Health Contest: FHIR for Women's Health
read article
InterSystems Interoperability Contest: Building Sustainable Solutions
read article
Contest: Share a Good Plan
read article
InterSystems Full Stack Contest 2022
read article
InterSystems Grand Prix Programming Contest 2022
read article
InterSystems Globals Contest
read article
Solving the Hash Code 2022 Practice Challenge with 70 lines of code
read article
Hasura Tips & Tricks Contest
read article
InterSystems Datasets Contest
read article
Featured ones: