You are given a binary string s and an integer m. You need to return an integer r. Where r = k%m, k is the binary equivalent of string s.
Example 1:
Input:
s = "101" 
m = 2
Output:
1
Explanation: Here k=5 because (101)_{2} = (5)_{10}.
Hence 5 mod 2 = 1.
Example 2:
Input:
s = "1000"
m = 4
Output:
0
Explanation: Here k=8 and m=4 hence 
r = k mod m = 8 mod 4 = 0.
Your Task:
You don't need to read input or print anything. Your task is to complete the function modulo() which takes the string s and integer m as input parameters and returns the value of r as described above.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Constraints:
1 <= len(s) <= 10^{7}
1 <= m <= 100

Difficulty: EASY
Tags: Bit manipulation

Mathematics
Skill types: Bit manipulation
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

Starter code:
#User function Template for python3



class Solution():

    def modulo(self, s, m):

        #your code goes here

Solutions:
class Solution:

	def modulo(self, s, m):
		k = int(s, 2)
		return k % m


class Solution:

	def modulo(self, s, m):
		rs = 0
		lenS = len(s)
		i = 0
		while i < lenS:
			while i < lenS and rs < m:
				rs = (rs << 1) + int(s[i])
				i += 1
			if rs >= m:
				rs = int(rs % m)
		return rs


class Solution:

	def modulo(self, s, m):
		c = int(s, 2)
		return c % m


class Solution:

	def modulo(self, s, m):
		a = int(s, 2)
		return a % m


class Solution:

	def modulo(self, s, m):
		n = len(s)
		s = s[::-1]
		res = 0
		p = [0] * n
		p[0] = 1
		tmp = 0
		for i in range(1, n):
			p[i] = 2 * p[i - 1] % m
		for i in range(n):
			if s[i] == '1':
				tmp += p[i]
			tmp %= m
		return tmp


class Solution:

	def modulo(self, s, m):
		r = int(s, 2)
		return r % m


class Solution:

	def modulo(self, s, m):
		dec = int(s, 2)
		return dec % m


class Solution:

	def modulo(self, s, m):
		x = int(s, 2)
		return x % m


class Solution:

	def modulo(self, s, m):
		decimal = 0
		for digit in s:
			if digit == '1':
				decimal = decimal * 2 + 1
			else:
				decimal = decimal * 2
		return decimal % m


class Solution:

	def modulo(self, s, m):
		n = int(s, 2)
		return n % m


class Solution:

	def modulo(self, s, m):
		num = int(s, 2)
		ans = num % m
		return ans


class Solution:

	def modulo(self, s, m):
		res = int(s, 2)
		return res % m


class Solution:

	def modulo(self, s, m):
		total = 0
		for x in s:
			total = (total * 2 + int(x)) % m
		return total


class Solution:

	def modulo(self, s, m):
		d = int(s, 2)
		return d % m


class Solution:

	def modulo(self, s, m):
		r = 0
		for c in s:
			r = (r * 2 + int(c)) % m
		return r


class Solution:

	def modulo(self, s, m):
		p = [1]
		for i in range(1, len(s) + 1):
			p.append(p[-1] * 2 % m)
		k = 0
		for i in range(len(s)):
			k = (k * 2 + int(s[i])) % m
		return k


class Solution:

	def modulo(self, s, m):
		number = int(s, 2)
		return number % m


class Solution:

	def modulo(self, s, m):
		r = 0
		for c in s:
			r = r * 2
			if c == '1':
				r += 1
			if r >= m:
				r -= m
		return r


import math

class Solution:

	def modulo(self, s, m):
		return int(s, 2) % m


class Solution:

	def modulo(self, s: str='0', m: int=1) -> int:
		if not all((char in '01' for char in s)):
			raise ValueError('Input string must be a binary string.')
		if m <= 0:
			raise ValueError('Modulus must be a positive integer greater than zero.')
		k = int(s, 2)
		r = k % m
		return r


class Solution:

	def modulo(self, s, m):
		t = int(s, 2)
		return t % m


class Solution:

	def modulo(self, s, m):
		mom = int(s, 2)
		return mom % m


class Solution:

	def modulo(self, s, m):
		v = 0
		for i in range(len(s)):
			v = (v * 2 + (1 if s[i] == '1' else 0)) % m
		return v % m


class Solution:

	def modulo(self, s, m):
		temp = 0
		pow = 1
		c = 0
		return int(s, 2) % m


class Solution:

	def modulo(self, s, m):
		r = 0
		n = len(s)
		power_of_2 = [1] * n
		for i in range(n - 2, -1, -1):
			power_of_2[i] = (power_of_2[i + 1] << 1) % m
		for i in range(n):
			if s[i] == '1':
				r = (r + power_of_2[i]) % m
		return r


class Solution:

	def modulo(self, s, m):
		b = 0
		a = len(s) - 1
		i = len(s) - 1
		p = 1
		while i >= 0:
			if s[i] == '1':
				b += p
				b = b % m
			p = p * 2
			p = p % m
			i -= 1
		return b


class Solution:

	def modulo(self, s, m):
		ans = 0
		power = 1
		for i in range(len(s) - 1, -1, -1):
			if s[i] == '1':
				ans += power
				ans %= m
			power *= 2
			power %= m
		return ans


class Solution:

	def modulo(self, s, m):
		n = len(s)
		prefix_mod = [0] * n
		prefix_mod[0] = int(s[0]) % m
		for i in range(1, n):
			prefix_mod[i] = (prefix_mod[i - 1] * 2 % m + int(s[i])) % m
		return prefix_mod[n - 1]


class Solution:

	def modulo(self, s, m):
		integerval = int(s, 2)
		ans = integerval % m
		return int(ans)


class Solution:

	def modulo(self, s, m):
		dig = int(s, 2)
		return dig % m


class Solution:

	def modulo(self, s, m):
		n = len(s)
		res = 0
		cur = 1
		for i in range(n - 1, -1, -1):
			if s[i] == '1':
				res += cur
				res %= m
			cur <<= 1
			cur %= m
		return res % m