LeetCode POTD: Binary String Generation and Kth Bit Extraction

LeetCode POTD šŸ’«: Description: Given two positive integersĀ nĀ andĀ k, the binary stringĀ SnĀ is formed as follows: -> S1 = "0" -> Si = Si - 1 + "1" + reverse(invert(Si - 1))Ā forĀ i > 1 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). For example, the first four strings in the above sequence are: -> S1 = "0" -> S2 = "011" -> S3 = "0111001" -> S4 = "011100110110001" ReturnĀ theĀ kthĀ bitĀ inĀ Sn. It is guaranteed thatĀ kĀ is valid for the givenĀ n. Here's my solution: https://lnkd.in/gQgs6AN9 #Python #DSA #Leetcode #DailyChallenge

  • graphical user interface, text, application, email

To view or add a comment, sign in

Explore content categories