You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given two positive integers n and k, the binary string Sn is formed as follows:
4
+
5
+
S1 = "0"
6
+
Si = Si - 1 + "1" + reverse(invert(Si - 1)) for i > 1
7
+
Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).
8
+
9
+
For example, the first four strings in the above sequence are:
10
+
11
+
S1 = "0"
12
+
S2 = "011"
13
+
S3 = "0111001"
14
+
S4 = "011100110110001"
15
+
Return the kth bit in Sn. It is guaranteed that k is valid for the given n.
0 commit comments