Count Subsequences Problem Statement
Given an integer array ARR
of size N
, your task is to find the total number of subsequences in which all elements are equal.
Explanation:
A subsequence of an array is derived by removing some of the elements of the array without changing the order of the remaining elements.
Input:
The first line contains an integer 'T' denoting the number of test cases. Each test case is as follows: The first line contains an integer 'N' denoting the size of the array. The second line contains 'N' space-separated integers representing the elements of the array.
Output:
For each test case, output the total number of subsequences where all elements are the same. Each test case's result should be printed on a new line.
Example:
Input:
2
3
1 1 2
4
3 3 3 3
Output:
3
14
Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 105
0 ≤ ARR[i] ≤ 109
- Time Limit: 1 second
Note:
The result must be calculated modulo 109 + 7. Implement the function; you don't need to print anything.
AnswerBot
1d
The task is to find the total number of subsequences in which all elements are equal in an integer array.
Iterate through the array and count the frequency of each element.
For each element, calculate t...read more
Help your peers!
Add answer anonymously...
Top Oracle Financial Services Software Associate Consultant interview questions & answers
Popular interview questions of Associate Consultant
Top HR questions asked in Oracle Financial Services Software Associate Consultant
>
Oracle Financial Services Software Associate Consultant Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app