Subset Sum Equal To K Problem Statement
Given an array/list of positive integers and an integer K, determine if there exists a subset whose sum equals K.
Provide true
if such a subset exists, otherwise return false
.
Example:
Input:
ARR = {1,2,3,4}, K = 4
Output:
true
Explanation:
There exist subsets like {1,3} and {4} where the sum is 4, so the output is true
.
Constraints:
1 ≤ T ≤ 5
1 ≤ N ≤ 10^3
0 ≤ ARR[i] ≤ 10^9
0 ≤ K ≤ 10^9
- Time Limit: 1 sec

AnswerBot
4mo
Given an array of positive integers and an integer K, determine if there exists a subset whose sum equals K.
Use dynamic programming to solve this problem efficiently
Create a 2D array to store if a sub...read more
Anonymous
5mo
def CheckForSequence(arr, n, k) : # Traverse the array from end # to start for i in range(n - 1, -1, -1) : # if k is greater than # arr[i] then subtract # it from k if (k >= arr[i]) : k = k - arr[i]; ...read more
Help your peers!
Add answer anonymously...
JPMorgan Chase & Co. Machine Learning Engineer interview questions & answers
A Machine Learning Engineer was asked Q. Subset Sum Equal To K Problem Statement Given an array/list of positive integers...read more
A Machine Learning Engineer was asked Q. Maximum Number by One Swap You are provided with an array of N integers represen...read more
A Machine Learning Engineer was asked Q. Paths in a Matrix Problem Statement Given an 'M x N' matrix, print all the possi...read more
Popular interview questions of Machine Learning Engineer
A Machine Learning Engineer was asked Q1. Subset Sum Equal To K Problem Statement Given an array/list of positive integers...read more
A Machine Learning Engineer was asked Q2. Maximum Number by One Swap You are provided with an array of N integers represen...read more
A Machine Learning Engineer was asked Q3. Paths in a Matrix Problem Statement Given an 'M x N' matrix, print all the possi...read more
>
JPMorgan Chase & Co. Machine Learning Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

