Tap here to switch tabs
Problem
Submissions

Problem: Sum of Subsequence Widths

Sum of Subsequence Widths gives an integer array and asks you to return the sum of maximum-minus-minimum widths for all nonempty subsequences, modulo a large prime.

Statement

The width of a sequence is defined as the difference between its maximum and minimum elements.

Given an integer array nums, return the sum of the widths of all non empty subsequences of nums.

Note: Since the final answer can be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Subsequence Widths

Sum of Subsequence Widths gives an integer array and asks you to return the sum of maximum-minus-minimum widths for all nonempty subsequences, modulo a large prime.

Statement

The width of a sequence is defined as the difference between its maximum and minimum elements.

Given an integer array nums, return the sum of the widths of all non empty subsequences of nums.

Note: Since the final answer can be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5