Asked inOla Cabs,SDE-2

Partition Equal Subset Sum Problem

Given an array ARR consisting of 'N' positive integers, determine if it is possible to partition the array into two subsets such that the sum of the elements in both subsets is equal.

Input:

The first line of input provides an integer 'T' indicating the number of test cases.
For each test case:
- The first line contains a single integer 'N', the size of the array.
- The second line contains 'N' space-separated positive integers representing the elements of the array.

Output:

Output 'true' for each test case if the array can be partitioned into subsets with equal sum, otherwise output 'false'. Each result should be on a new line.

Example:

Input:
1
6
2 3 3 3 4 5
Output:
true
Explanation:

The array can be partitioned into two subsets, [2, 3, 5] and [3, 3, 4], both having a sum of 10.

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 100
  • 1 <= ARR[i] <= 100
Note:
You do not need to print anything, as the implementation handles only computing the results.
AnswerBot
4mo

The problem is to determine if it is possible to partition an array into two subsets with equal sum.

  • Use dynamic programming to solve this problem efficiently.

  • Create a 2D array to store the subset sum ...read more

Help your peers!
Select
Add answer anonymously...

Ola Cabs SDE-2 interview questions & answers

A SDE-2 was asked Q. For each element in an array, find the sum of the smallest element to its left a...read more
A SDE-2 was asked Q. Can you explain the different types of joins in SQL and how to calculate the ave...read more
A SDE-2 was asked Q. Job Sequencing Problem Statement You are provided with a N x 2 2-D array called ...read more

Popular interview questions of SDE-2

A SDE-2 was asked Q1. For each element in an array, find the sum of the smallest element to its left a...read more
A SDE-2 was asked Q2. Can you explain the different types of joins in SQL and how to calculate the ave...read more
A SDE-2 was asked Q3. Job Sequencing Problem Statement You are provided with a N x 2 2-D array called ...read more
Ola Cabs SDE-2 Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits