Closest Subsequence Sum
Problem Overview
- Find a subsequence of nums whose sum is closest to goal and return the minimum absolute difference.
- Input: integer array nums and integer goal; Output: min abs(sum − goal); Constraints: 1 ≤ n ≤ 40, nums[i] ∈ [−1e7, 1e7], goal ∈ [−1e9, 1e9].
- Domain: target-matching and optimization tasks (e.g., budgeting, resource allocation).
- Source: Salesforce interviews; a common coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
