
Asked in Capgemini
Count Good Subsets Problem Statement
Given an array ARR
of size N
consisting of distinct elements, your task is to determine the total number of good subsets. A subset is considered a good subset if the elements can be rearranged such that every element divides the next element in order. Subsets are regarded as different if there is at least one element that exists in one but not the other.
Example:
Input:
ARR = [2, 4, 5, 15]
Output:
6
Explanation:
The good subsets are: (2), (4), (5), (15), (2,4), and (5,15). Thus, the total number of good subsets is 6.
Input:
"The first line contains an integer 'T' representing the number of test cases. Each test case has the following structure: The first line contains an integer 'N' indicating the number of elements in the array. The second line contains 'N' space-separated integers, comprising the array 'ARR'."
Output:
"For each test case, print a single integer that represents the total number of good subsets. Print each test case's result on a new line."
Constraints:
1 <= T <= 10
1 <= N <= 10^5
1 <= ARR[i] <= 10^5
- All elements in
ARR
are unique. - Time limit: 1 sec
Be the first one to answer
Add answer anonymously...
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for Capgemini Software Developer Intern
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
C++ Interview Questions and Answers
150 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

