String Rotation Challenge: Concatenation Trick

Day 20/100: The "Cheat Code" for String Rotations 🔄 I’m back on the grind! Today’s challenge was checking if one string is a rotation of another (e.g., "waterbottle" and "erbottlewat"). The Strategy: Instead of writing complex loops to shift characters, I used the Concatenation Trick: 1️⃣ Check if lengths are equal. 2️⃣ Create a new string by adding the first string to itself (s1 + s1). 3️⃣ Check if the second string exists inside that combined string. It’s a simple, elegant O(n) solution that shows how sometimes "working smarter" with data structures beats "working harder" with loops. 20% of the way there. Let's keep moving! 🚀 #100DaysOfCode #Java #DSA #Strings #ProblemSolving #Unit2 #CodingJourney #LearnInPublic

  • text

To view or add a comment, sign in

Explore content categories