Tap here to switch tabs
Problem
Submissions

Problem: Sum of Subsequence Widths

med
30 min
Try to solve the Sum of Subsequence Widths problem.

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

med
30 min
Try to solve the Sum of Subsequence Widths problem.

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