← ALL NOTES
String

1545. Find Kth Bit in Nth Binary String

S1 = "0", and Sn = S(n-1) + "1" + reverse(invert(S(n-1))). Return the k-th bit (1-indexed) of Sn. The string is self-similar, so recurse on its structure instead of building it.

Loading…