Computer Science, asked by haritha13400, 8 months ago

You are given a set S of banned digits. How many numbers formed only of the digits \{0, 1, 2, .., 9\} are less than a given number N? Note that numbers don't have leading 0s and the number 0 is a valid number. Note that N can contain banned digits.
Input format:
The first line contains 10 binary values. The ith(0≤i≤9) one is 1 if the digit i is banned and 0 otherwise.
The second line contains the number N.
Output format:
Print the answer on the first line.

Example:
Input:
0 0 0 0 1 0 0 0 0 0
25
Output:
22
Explanation:
The only banned digit is 4. The banned numbers are: 4 14 24 Note that 0 is counted while 25 is not (the numbers should be

Answers

Answered by meghnaabhang6666
0

Answer:

The idea is take value of open bracket ‘(‘ as 1 and value of close bracket ‘)’ as -1. Now start finding the prefix sum of the given string. The farthest index, say maxi, where the value of sum is 0 is the index upto which longest balanced prefix exists. So the answer would be maxi + 1.

Below is the implementation of this approach:

Explanation:

i don't no these sry

Similar questions
Math, 4 months ago