less than 1 minute read

Given a list of integers nums and an integer target, return the number of sublists whose sum is equal to target.

Constraints

  • n ≤ 100,000 where n is the length of nums

https://binarysearch.com/problems/Number-of-Sublists-With-Sum-of-Target

Examples

Example 1

Input

  • nums = [2, 0, 2]
  • target = 2

Output

  • answer = 4

Explanation

We have these sublists whose sum is 2: [2], [2, 0], [0, 2], [2]

Solution

Leave a comment