BackmediumIntroduction to Arrays Salesforce

Optimal Weighted Sum Subsequence Solution

Problem Statement

Given an array of integers `sequence` where each element has a corresponding weight in the `weights` array, find the maximum sum subsequence by selecting a subset of elements from `sequence`, considering their respective weights in `weights`. The subsequence does not need to be contiguous.

Constraints

  • {"name":"sequence length","type":"integer","min":1,"max":1000}
  • {"name":"weights length","type":"integer","min":1,"max":1000}
  • {"name":"sequence and weights correspondence","type":"boolean","description":"The lengths of sequence and weights must be equal"}
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free