Tap here to switch tabs
Problem
Submissions

Problem: Valid Subarrays With Matching Sum Digits II

Try to solve the Valid Subarrays With Matching Sum Digits II problem.

Statement

You are given an integer array nums and an integer x.

A contiguous subarray is considered valid if the sum of its elements satisfies both of the following conditions:

  • The most significant digit (first digit) of the sum is equal to x.

  • The least significant digit (last digit) of the sum is equal to x.

Return the total number of valid subarrays in nums.

Constraints:

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

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq x ≤9\leq 9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Valid Subarrays With Matching Sum Digits II

Try to solve the Valid Subarrays With Matching Sum Digits II problem.

Statement

You are given an integer array nums and an integer x.

A contiguous subarray is considered valid if the sum of its elements satisfies both of the following conditions:

  • The most significant digit (first digit) of the sum is equal to x.

  • The least significant digit (last digit) of the sum is equal to x.

Return the total number of valid subarrays in nums.

Constraints:

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

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq x ≤9\leq 9