Please read the new rule regarding the restriction on the use of AI tools. ×

RaghavGupta22's blog

By RaghavGupta22, history, 23 months ago, In English

Problem Description

You are given an array of size N.

Let us define the value of subsequence as the product of its elements.

Find the sum of values of all distinct subsequences. since the answer can be large return it modulo 10^9+7.

Constraints:

  • 1 <= N <= 10^5
  • 1 <= A[i] <= 10^6

Sample input:

  1. N = 3, A = [1,2,3] Ans = 23 There are 7 distinct subsequences 3, 2, 1, 3*2 = 6, 3*1 = 3, 2*1 = 2, 3*2*1 = 6 then 3+2+1+6+3+2+6 = 23.

  2. N = 3, A = [3, 2, 2] Ans = 27 There are 5 distinct subsequences

  • Vote: I like it
  • +4
  • Vote: I do not like it

| Write comment?
»
23 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Stop asking Online assessment questions

  • »
    »
    23 months ago, # ^ |
      Vote: I like it +9 Vote: I do not like it

    Why one should stop asking Online assessment questions, if you don't want to answer then just pass maybe someone else wants to answer it. I faced this question but was unable to solve it and want to know how to solve it that's my only reason for asking.

    Maybe you should stop saying that.