class Solution:
def findKthBit(self, n: int, k: int) -> str:
dp = ["0"]
def rev(val):
return val[::-1]
def inv(val):
res = ""
for i in val:
if i == "1":
res +="0"
elif i == "0":
res += "1"
return res
for i in range(n-1):
s = dp[-1] + "1"
s += rev(inv(dp[-1]))
dp.append(s)
#print(dp)
return dp[n-1][k-1]
top of page
Forum: Forum
bottom of page