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.
Be the first one to answer
Add answer anonymously...
Oracle Financial Services Software Associate Consultant Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter