Search
⌘K

Leetcode 1545. Find Kth Bit in Nth Binary String

Given S1 = "0" and Si = S{i-1} + "1" + reverse(invert(S{i-1})), return the k-th bit of S_n. Use the string's length (2^n−1) and its central symmetry/inversion property to compute the bit recursively by reflecting k across the middle and flipping bits as needed, avoiding full string construction.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.