Rahul kumar’s Post

Day 27/100 – DSA Practice Solved LeetCode 459: Repeated Substring Pattern today. Key Insight: If a string s is formed by repeating a substring, then it will always exist inside: (s + s)[1:-1] Why this works: Doubling the string generates all possible rotations Removing first & last characters avoids trivial matches If s is found in this modified string, it confirms a repeating pattern This elegant trick reduces the problem to a simple one-liner and highlights the power of pattern observation in strings. Approach Used: return s in (s + s)[1:-1] Constant progress > Perfection. On to the next one! #Day27 #100DaysOfCode #DSA #LeetCode #Python #CodingJourney #ProblemSolving

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories