Given a number N and a value K. From the right, set the Kth bit in the binary representation of N. The position of Least Significant Bit(or last bit) is 0, the second last bit is 1 and so on. 
Example 1:
Input:
N = 10 
K = 2
Output:
14
Explanation:
Binary representation of the given number
10 is: 1 0 1 0, number of bits in the 
binary reprsentation is 4. Thus 2nd bit
from right is 0. The number after changing
this bit to 1 is: 14(1 1 1 0).
Example 2:
Input:
N = 15 
K = 3
Output:
15
Explanation:
The binary representation of the given
number 15 is: 1 1 1 1, number of bits
in the binary representation is 4. Thus
3rd bit from the right is 1. The number
after changing this bit to 1 is
15(1 1 1 1).
Your Task:  
You don't need to read input or print anything. Your task is to complete the function setKthBit() which takes two integer N and K as input parameter and returns an integer after setting the K'th bit in N.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 10^{9}
0 <= K < X, where X is the number of bits in the binary representation of N.

Difficulty: EASY
Tags: Bit manipulation

Data structures
Skill types: Bit manipulation

Data structures
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3
class Solution:
	def setKthBit(self, N, K):
		# code here

Solutions:
class Solution:

	def setKthBit(self, N, K):
		return N | 1 << K


class Solution:

	def setKthBit(self, N, K):
		b = bin(N)[2:]
		q = b[::-1]
		j = list(q)
		j[K] = '1'
		e = ''.join(j)
		e = e[::-1]
		t = int(e, 2)
		return t


class Solution:

	def setKthBit(self, N, K):
		self.N = N
		self.K = K
		KK = K * -1 - 1
		nn = bin(N)[2:]
		l_n = list(nn)
		l_n[KK] = '1'
		r = ''.join(l_n)
		r = int(r, 2)
		return r


class Solution:

	def setKthBit(self, n, k):
		kno = 2 ** k
		return n | kno


class Solution:

	def setKthBit(self, N, K):
		b = bin(N)[2:]
		b = b[::-1]
		lst = list(b)
		for i in lst:
			lst[K] = '1'
		lst = lst[::-1]
		d = ''.join(lst)
		return int(d, 2)


class Solution:

	def setKthBit(self, n, k):
		return n | 1 << k


class Solution:

	def setKthBit(self, N, K):
		binario = bin(N)[2:]
		binarios = []
		resultado = ''
		for l in binario:
			binarios += [l]
		binarios[-K - 1] = '1'
		for i in binarios:
			resultado += i
		return int(resultado, 2)


def decimal(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 setKthBit(self, N, K):
		a = str(bin(N))
		a = list(a[2:])
		a.reverse()
		if a[K] == '0':
			a[K] = '1'
		a.reverse()
		s = ''
		s = int(s.join(a))
		return decimal(s)


class Solution:

	def setKthBit(self, N, K):
		binn = bin(N)[2:][::-1]
		M = ''
		for i in range(len(binn)):
			if i == K:
				M += '1'
			else:
				M += binn[i]
		summ = 0
		for i in range(len(M)):
			summ += 2 ** i * int(M[i])
		return summ


class Solution:

	def setKthBit(self, N, K):
		binary = list(bin(N)[2:])
		binary[-K - 1] = 1
		binary = list(map(str, binary))
		return int(''.join(binary), 2)


class Solution:

	def setKthBit(self, N, K):
		(cnt, res) = (0, 0)
		while N > 0:
			if cnt == K:
				res += 2 ** cnt * 1
			else:
				res += 2 ** cnt * (N & 1)
			cnt += 1
			N = N >> 1
		return res


class Solution:

	def setKthBit(self, N, K):
		a = 1 << K
		b = N | a
		return b


class Solution:

	def setKthBit(self, n, k):
		ans = ''
		while n > 0:
			if n % 2 == 0:
				ans += '0'
			else:
				ans += '1'
			n = n // 2
		return int((ans[:k] + '1' + ans[k + 1:])[::-1], 2)


class Solution:

	def setKthBit(self, N, K):
		N_str_binary = str(bin(N))[2:]
		N_str_binary_list = list(N_str_binary)
		l = len(N_str_binary_list)
		N_str_binary_list[l - K - 1] = '1'
		N_str_binary = ''.join(N_str_binary_list)
		result = int(N_str_binary, 2)
		return result


class Solution:

	def setKthBit(self, N, K):
		mask = 1 << K
		if N | mask != N:
			N = N ^ mask
		return N


class Solution:

	def setKthBit(self, N, K):
		M = int('1' + '0' * K, 2)
		return M | N


class Solution:

	def setKthBit(self, N, K):
		A = []
		while N > 0:
			A.append(N % 2)
			N = N // 2
		A[K] = 1
		for i in range(len(A)):
			N = N + A[i] * 2 ** i
		return N


class Solution:

	def setKthBit(self, N, K):
		mask = 1 << K
		ans = N | mask
		return ans


class Solution:

	def setKthBit(self, N, K):
		l = list(bin(N))[2:]
		l[-K - 1] = str(int(l[-K - 1]) or 1)
		return int(''.join(l), 2)


class Solution:

	def setKthBit(self, N, K):
		return N if N & 2 ** K else N | 2 ** K


class Solution:

	def setKthBit(self, N, K):
		return N if N & 1 << K else N | 1 << K


class Solution:

	def setKthBit(self, N, K):
		N = bin(N)
		l = len(N)
		N = N[:l - K - 1] + '1' + N[l - K:]
		return int(N, 2)


class Solution:

	def setKthBit(self, N, K):
		bit_mask = 1 << K
		new_num = bit_mask | N
		return new_num


class Solution:

	def setKthBit(self, N, K):
		b = str(bin(N))
		b = b[2:]
		bl = list(b)
		iteration = -1
		for i in range(len(bl) - 1, -1, -1):
			iteration += 1
			if iteration == K:
				bl[i] = '1'
		bs = ''.join(bl)
		res = int(bs, 2)
		return res


class Solution:

	def setKthBit(self, N, K):
		x = bin(N)[2:]
		pos = len(x) - K - 1
		return int(x[:pos] + '1' + x[pos + 1:], 2)


class Solution:

	def setKthBit(self, n, k):
		pos = -(k + 1)
		bn = bin(n)[2:]
		if bn[pos] == '1':
			return n
		else:
			return 2 ** k + n


class Solution:

	def setKthBit(self, n, k):
		num = bin(n)[2:]
		if num[len(num) - k - 1] == '1':
			return n
		else:
			return 2 ** k + n


class Solution:

	def setKthBit(self, N, K):
		one = 1
		for _ in range(K):
			one <<= 1
		return N | one


class Solution:

	def setKthBit(self, n, k):
		if (n >> k) % 2 == 1:
			return n
		return n + 2 ** k


class Solution:

	def setKthBit(self, N, K):
		if N & 1 << K == 0:
			ans = N | 1 << K
		else:
			ans = N | N & 0 << K
		return ans


class Solution:

	def setKthBit(self, N, K):
		mask = 1 << K
		result = N | mask
		return result


class Solution:

	def setKthBit(self, N, K):
		x = list(bin(N)[2:])
		x[len(x) - 1 - K] = '1'
		return int(''.join(x), 2)


class Solution:

	def setKthBit(self, N, K):
		a = bin(N).replace('0b', '')
		b = str(a)
		b.split()
		d = list(b)
		c = len(b) - 1 - K
		d[c] = 1
		d.reverse()
		res = 0
		for i in range(0, len(d)):
			c = int(d[i])
			res = res + c * 2 ** i
		return res


class Solution:

	def setKthBit(self, N, K):
		b = str(bin(N))[2:]
		a = list(map(str, b))
		if a[-(K + 1)] != '1':
			a[-(K + 1)] = '1'
		h = ''.join(a)
		return int(h, 2)


class Solution:

	def setKthBit(self, N, K):
		bin_N = bin(N)
		bin_N_num = bin_N[2:]
		if bin_N_num[len(bin_N_num) - K - 1] == '1':
			return N
		else:
			return N + 2 ** K


class Solution:

	def setKthBit(self, N, K):
		s = 0
		s = bin(N)[2:]
		c = 0
		d = []
		for i in map(int, s):
			d.append(i)
		K = K + 1
		d[-K] = 1
		t = ''.join(map(str, d))
		return int(t, 2)


class Solution:

	def setKthBit(self, N, K):
		p = bin(N)
		su = 0
		q = p[2:]
		r = q[::-1]
		f = list(r)
		f[K] = '1'
		for i in range(len(f)):
			su += int(f[i]) * 2 ** i
		return su


class Solution:

	def setKthBit(self, N, K):
		s = bin(N)[2:]
		l = list(s)
		l[len(l) - K - 1] = '1'
		binary = ''.join(l)
		return int(binary, 2)


class Solution:

	def setKthBit(self, n, k):
		if n >> k & 1:
			return n
		else:
			xor = 1 << k
			n = n ^ xor
			return n


class Solution:

	def setKthBit(self, N, K):
		binary = 0
		r = 1
		while N != 0:
			rem = N % 2
			N = N // 2
			binary = binary + rem * r
			r = r * 10
		deci = 0
		i = 0
		while binary != 0:
			rem = binary % 10
			binary = binary // 10
			if i == K and rem == 0:
				rem = 1
				deci += 2 ** i * rem
				i = i + 1
			else:
				deci += 2 ** i * rem
				i = i + 1
		return deci


class Solution:

	def setKthBit(self, N, K):
		bin_N = bin(N)[2:]
		K = K + 1
		list_n = list(bin_N)
		if list_n[-K] == '1':
			pass
		else:
			list_n[-K] = '1'
		dec_n = int(''.join(list_n), 2)
		return dec_n


class Solution:

	def setKthBit(self, N, K):
		return N | 2 ** K


class Solution:

	def setKthBit(self, n, k):
		s = []
		st = ''
		if n % 2:
			s += '1'
		else:
			s += '0'
		while True:
			if n == 1:
				break
			n = n // 2
			if n % 2 == 0:
				s.append('0')
			else:
				s.append('1')
		s[k] = '1'
		for i in range(len(s) - 1, -1, -1):
			st += s[i]
		return int(st, 2)