Tap here to switch tabs
Problem
Submissions

Problem: Find the Divisibility Array of a String

med
30 min
Try to solve the Find the Divisibility Array of a String problem.

Statement

You are given a 00 indexed string word of length n consisting of numeric digits, and a positive integer m.

The divisibility array div of word is an integer array of length n where:

  • div[i] = 1 if the numeric value represented by the prefix word[0...i] is divisible by m

  • div[i] = 0 otherwise

Return the divisibility array of word.

Constraints:

  • 1≤n≤1051 \leq n \leq 10^5

  • word.length =n= n

  • word consists of digits from 00 to 99

  • 1≤m≤1091 \leq m \leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Divisibility Array of a String

med
30 min
Try to solve the Find the Divisibility Array of a String problem.

Statement

You are given a 00 indexed string word of length n consisting of numeric digits, and a positive integer m.

The divisibility array div of word is an integer array of length n where:

  • div[i] = 1 if the numeric value represented by the prefix word[0...i] is divisible by m

  • div[i] = 0 otherwise

Return the divisibility array of word.

Constraints:

  • 1≤n≤1051 \leq n \leq 10^5

  • word.length =n= n

  • word consists of digits from 00 to 99

  • 1≤m≤1091 \leq m \leq 10^9