Given a Binary Number B, find its decimal equivalent.
 
Example 1:
Input: B = 10001000
Output: 136
Example 2:
Input: B = 101100
Output: 44
 
Your Task:
You don't need to read or print anything. Your task is to complete the function binary_to_decimal() which takes the binary number as string input parameter and returns its decimal equivalent.
 
Expected Time Complexity: O(K * Log(K)) where K is number of bits in binary number.
Expected Space Complexity: O(1)
 
Constraints:
1 <= number of bits in binary number  <= 16

Difficulty: EASY
Expected Time Complexity: O(K * Log(K)) where K is number of bits in binary number.
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:

	def binary_to_decimal(self, str):

		# Code here

Solutions:
class Solution:

	def binary_to_decimal(self, str):
		k = int(str, 2)
		return k


class Solution:

	def binary_to_decimal(self, str):
		n = int(str)
		new = 0
		for i in range(len(str)):
			rem = n % 10
			new = new + rem * pow(2, i)
			n = n // 10
		return new


class Solution:

	def binary_to_decimal(self, str):
		a = int(str, 2)
		return a


class Solution:

	def binary_to_decimal(self, str):
		j = len(str) - 1
		sum = 0
		for i in range(len(str)):
			if int(str[j]) == 0:
				sum += 0
			else:
				sum += 2 ** i
			j -= 1
		return sum


class Solution:

	def binary_to_decimal(self, str):
		c = int(str, 2)
		return c


class Solution:

	def binary_to_decimal(self, str):
		str = str[::-1]
		summ = 0
		for i in range(len(str)):
			summ += 2 ** i * int(str[i])
		return summ


class Solution:

	def binary_to_decimal(self, str):
		C = int(str, 2)
		return C


class Solution:

	def binary_to_decimal(self, str):
		s = str[::-1]
		ans = 0
		for i in range(len(s)):
			if s[i] == '1':
				ans += pow(2, i)
		return ans


class Solution:

	def binary_to_decimal(self, str):
		g = int(str, 2)
		return g


class Solution:

	def binary_to_decimal(self, str):
		char1 = []
		res = 0
		for char in str:
			char1.append(int(char))
		for i in range(len(char1)):
			res += char1.pop() * 2 ** i
		return res


class Solution:

	def binary_to_decimal(self, str):
		ans = 0
		k = 0
		for i in range(len(str) - 1, -1, -1):
			ans = ans + int(str[i]) * pow(2, k)
			k += 1
		return ans


class Solution:

	def binary_to_decimal(self, str):
		num = 0
		j = 0
		s = str[::-1]
		for i in s:
			if i == '1':
				num = num + 2 ** j
			j += 1
		return num


import math

class Solution:

	def binary_to_decimal(self, str):
		s = int(str)
		an = 0
		p = 0
		while s > 0:
			rem = s % 10
			an = an + rem * 2 ** p
			p += 1
			s = s // 10
		return an


class Solution:

	def binary_to_decimal(self, str):
		str = str[::-1]
		i = 0
		res = 0
		while i < len(str):
			if str[i] == '1':
				res += 2 ** i
			i += 1
		return res


class Solution:

	def binary_to_decimal(self, st):
		return int('0b' + st, 2)


class Solution:

	def binary_to_decimal(self, str):
		lst = list(str)
		add = 0
		number = len(lst) - 1
		for i in range(len(lst)):
			add = add + int(lst[i]) * 2 ** number
			number = number - 1
		return add


class Solution:

	def binary_to_decimal(self, str):
		lst = list(str)
		store = 0
		num = len(lst) - 1
		for i in range(len(lst)):
			store = store + int(lst[i]) * 2 ** num
			num = num - 1
		return store


class Solution:

	def binary_to_decimal(self, str):
		x = int(str, 2)
		return x


class Solution:

	def binary_to_decimal(self, str):
		ans = 0
		curr = 1
		for i in str[::-1]:
			if i == '1':
				ans += curr
			curr *= 2
		return ans


class Solution:

	def binary_to_decimal(self, B):
		decimal = 0
		power = 0
		for i in range(len(B) - 1, -1, -1):
			if B[i] == '1':
				decimal += 2 ** power
			power += 1
		return decimal


class Solution:

	def binary_to_decimal(self, str):
		bin = int(str)
		a = 0
		for i in range(0, len(str)):
			d = bin % 10
			a = a + pow(2, i) * d
			bin = int(bin / 10)
		return a


class Solution:

	def binary_to_decimal(self, str):
		n = int(str, 2)
		return n


class Solution:

	def binary_to_decimal(self, str):
		sum = 0
		for (i, v) in enumerate(str):
			if v == '1':
				sum += 2 ** (len(str) - 1 - i)
		return sum


class Solution:

	def binary_to_decimal(self, str):
		str = int(str)
		sol = 0
		i = 0
		while str != 0:
			digit = str % 10
			if digit != 0:
				sol += pow(2, i)
			i += 1
			str = str // 10
		return sol


class Solution:

	def binary_to_decimal(self, str):
		(c, res) = (0, 0)
		str = str[::-1]
		for i in str:
			res = res + int(i) * pow(2, c)
			c = c + 1
		return res


class Solution:

	def binary_to_decimal(self, str):
		sum = 0
		n = len(str)
		for i in range(n):
			sum += 2 ** i * int(str[-(i + 1)])
		return sum


class Solution:

	def binary_to_decimal(self, str):
		dec = int(str, 2)
		return dec


class Solution:

	def binary_to_decimal(self, str):
		s = int(str, 2)
		return s


class Solution:

	def binary_to_decimal(self, str):
		s = str[::-1]
		res = 0
		mul = 1
		for i in s:
			res += mul * int(i)
			mul *= 2
		return res


class Solution:

	def binary_to_decimal(self, str):
		i = int(str, 2)
		return i


class Solution:

	def binary_to_decimal(self, s):
		b = int(s)
		n = b
		d = 0
		ba = 1
		while n > 0:
			re = n % 10
			d = d + re * ba
			n = n // 10
			ba = ba * 2
		return d


class Solution:

	def binary_to_decimal(self, str):
		n = len(str)
		dec = 0
		power = 0
		for i in range(n - 1, -1, -1):
			if str[i] == '1':
				dec += 1 << power
			power += 1
		return dec


class Solution:

	def binary_to_decimal(self, str):
		ans = 0
		count = 0
		for i in str[::-1]:
			ans += 2 ** count * int(i)
			count += 1
		return ans


class Solution:

	def binary_to_decimal(self, str):
		ip = int(str)
		number = 0
		count = 0
		while ip > 0:
			rem = ip % 10
			ip = (ip - rem) // 10
			number = number + 2 ** count * rem
			count += 1
		return number


class Solution:

	def binary_to_decimal(self, str):
		num = int(str, 2)
		return num


class Solution:

	def binary_to_decimal(self, str):
		n = int(str)
		sum = 0
		i = 0
		while n != 0:
			rem = n % 10
			sum = sum + rem * pow(2, i)
			n = n // 10
			i = i + 1
		return sum


class Solution:

	def binary_to_decimal(self, str):
		K = int(str, 2)
		return K


class Solution:

	def binary_to_decimal(self, str):
		sum1 = 0
		count = 0
		for i in str[::-1]:
			if i == '1':
				sum1 += 2 ** count
			count += 1
		return sum1


class Solution:

	def binary_to_decimal(self, str):
		num = int(str)
		dec = 0
		pow = 1
		while num != 0:
			bit = num % 10
			dec = dec + bit * pow
			pow = pow * 2
			num = int(num / 10)
		return dec


class Solution:

	def binary_to_decimal(self, str):
		a = str[::-1]
		b = 0
		for i in range(len(a)):
			if a[i] == '1':
				b += 2 ** i
		return b


class Solution:

	def binary_to_decimal(self, str):
		sum = 0
		length = len(str) - 1
		for item in str:
			sum = sum + int(item) * pow(2, length)
			length = length - 1
		return sum


class Solution:

	def binary_to_decimal(self, str):
		num = int(str)
		dec_value = 0
		base = 1
		temp = num
		while temp:
			last_digit = temp % 10
			temp = int(temp / 10)
			dec_value += last_digit * base
			base = base * 2
		return dec_value


class Solution:

	def binary_to_decimal(self, str):
		i = 0
		dec = 0
		for j in range(len(str) - 1, -1, -1):
			dec += int(str[j]) * 2 ** i
			i += 1
		return dec


class Solution:

	def binary_to_decimal(self, binary):
		(decimal, i) = (0, 0)
		binary_new = int(binary)
		while binary_new != 0:
			dec = binary_new % 10
			decimal = decimal + dec * pow(2, i)
			binary_new = binary_new // 10
			i += 1
		return decimal


class Solution:

	def binary_to_decimal(self, str):
		e = 0
		d = 0
		for i in range(len(str) - 1, -1, -1):
			if str[i] == '1':
				s = 2 ** e
				d = d + s
			e += 1
		return d


class Solution:

	def binary_to_decimal(self, str):
		str = int(str)
		power = 0
		sum = 0
		while str > 0:
			r = str % 10
			if r == 1:
				sum = sum + 2 ** power
			power += 1
			str = str // 10
		return sum


class Solution:

	def binary_to_decimal(self, str):
		power = 0
		sum = 0
		for i in range(len(str) - 1, -1, -1):
			if str[i] == '1':
				sum = sum + 2 ** power
			power += 1
		return sum


class Solution:

	def binary_to_decimal(self, str):
		b = int(str, 2)
		return b


class Solution:

	def binary_to_decimal(self, n):
		n = int(n)
		decimal = 0
		power = 1
		while n > 0:
			rem = n % 10
			n = n // 10
			decimal += rem * power
			power = power * 2
		return decimal


class Solution:

	def binary_to_decimal(self, str):
		v = int(str, 2)
		return v


class Solution:

	def binary_to_decimal(self, str):
		x = len(str) - 1
		k = 0
		d = 0
		for i in range(len(str)):
			d += 2 ** x * int(str[i])
			x -= 1
		return d


class Solution:

	def binary_to_decimal(self, str):
		num = int(str)
		n = 1
		sum = 0
		while num > 0:
			rem = num % 10
			sum = sum + rem * n
			n = n * 2
			num = num // 10
		return sum


import math

class Solution:

	def binary_to_decimal(self, x):
		sum = 0
		for i in range(len(x)):
			sum = sum + int(x[i]) * math.pow(2, len(x) - 1 - i)
		return int(sum)


class Solution:

	def binary_to_decimal(self, str):
		temp = int(str)
		res = 0
		base = 1
		while temp:
			i = temp % 10
			temp = temp // 10
			res += i * base
			base *= 2
		return res


class Solution:

	def binary_to_decimal(self, str):
		binary_num = str
		decimal = int(binary_num, 2)
		return decimal


class Solution:

	def binary_to_decimal(self, str):
		sum = 0
		n = len(str) - 1
		for i in str:
			if i == '1':
				sum = sum + 2 ** n
			n = n - 1
		return sum


class Solution:

	def binary_to_decimal(self, str):
		num = str
		dec_num = 0
		for (index, string) in enumerate(str[::-1]):
			dec_num = dec_num + pow(2, index) * int(string)
		return dec_num


class Solution:

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