Tap here to switch tabs
Problem
Submissions

Problem: Length of the Longest Subsequence That Sums to Target

Length of the Longest Subsequence That Sums to Target asks you to choose a subsequence of an array whose elements sum to the target and return its greatest length, or minus one if none exists.

Statement

You are given an integer array nums and an integer target.

Return the length of the longest subsequence of nums whose elements sum to target. If no such subsequence exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤1000\leq 1000

  • 1≤1 \leq target ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Length of the Longest Subsequence That Sums to Target

Length of the Longest Subsequence That Sums to Target asks you to choose a subsequence of an array whose elements sum to the target and return its greatest length, or minus one if none exists.

Statement

You are given an integer array nums and an integer target.

Return the length of the longest subsequence of nums whose elements sum to target. If no such subsequence exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤1000\leq 1000

  • 1≤1 \leq target ≤1000\leq 1000