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
4mo
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...
Oracle Financial Services Software Associate Consultant interview questions & answers
An Associate Consultant was asked 3mo agoQ. Write a function to reverse a string in Java.
An Associate Consultant was asked 8mo agoQ. How can you swap two numbers without using a temporary variable?
An Associate Consultant was asked 9mo agoQ. Explain the concepts of OOPs.
Popular interview questions of Associate Consultant
An Associate Consultant was asked 3mo agoQ1. Write a function to reverse a string in Java.
An Associate Consultant was asked 8mo agoQ2. How can you swap two numbers without using a temporary variable?
An Associate Consultant was asked 8mo agoQ3. Write pseudocode to determine if a string is a palindrome.
>
Oracle Financial Services Software Associate Consultant 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

