Rotate String to Match Goal in 100 Days of Code Challenge

🚀 Day 25/100 Days of Code Challenge 🔥 Problem: Rotate String(Leetcode 796) We are given two strings s and goal. 👉 We need to check if we can rotate string s (move first character to last again and again) to make it equal to goal. 📌 Example: abcde → bcdea → cdeab → deabc → eabcd ⚙️ Approach Check if lengths of both strings are equal Concatenate string with itself → s + s Check if goal exists inside the new string ⏱️ Complexity Time Complexity: O(n) Space Complexity: O(n) 📚 What I Learned ✔️ Simple tricks can save time ✔️ Avoid unnecessary loops ✔️ Think smart, not hard 💪 Day by day improving 🚀 #100DaysOfCode #Coding #Java #DSA #LearningJourney

  • text

To view or add a comment, sign in

Explore content categories