🚀 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
Rotate String to Match Goal in 100 Days of Code Challenge
More Relevant Posts
-
🚀 Day 72 — LeetCode Practice 🚀 Today’s problem: Sorting the Sentence 💡 What I learned today: • Practiced string manipulation and splitting techniques • Understood how to extract numbers from characters using ASCII logic • Learned to map words to correct positions using indexing • Improved attention to detail while handling edge cases 🧠 Key idea: Each word has a number at the end → use it to place the word in the correct position → then remove the number and rebuild the sentence. ✨ Consistency is slowly turning confusion into clarity. #Day72 #LeetCode #Java #ProblemSolving #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 7 of #LeetCode Challenge 🔍 Problem: Sqrt(x) 💡 Approach: Used the built-in Math.sqrt() function to compute the square root and then typecasted it to an integer to get the floor value. 🧠 Key Concept: Understanding how to convert a floating-point result into an integer using typecasting. 🔥 #Day7 #LeetCode #Java #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 95 - LeetCode Journey Solved LeetCode 1700: Number of Students Unable to Eat Lunch in Java ✅ At first it looks like a simulation problem using queue + stack… but the real trick is to avoid simulation completely. Instead of rotating the queue again and again, I simply counted preferences and matched them with sandwiches. Smart counting beats brute force 💡 Key takeaways: • Avoid unnecessary simulation • Use counting instead of queue operations • Greedy thinking simplifies the problem • Writing clean and optimal logic ✅ All test cases passed ⚡ O(n) time and O(1) space Sometimes the best solution is not doing what the problem is asking literally 🔥 #LeetCode #DSA #Java #Greedy #ProblemSolving #CodingJourney #InterviewPrep #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
Solved today’s LeetCode Daily Challenge — 396. Rotate Function At first, the problem looked confusing because of array rotations and formulas 😅 But after understanding the pattern, it became much easier. What the problem says in simple words: We rotate the array again and again and calculate a value using: (index × element) Then we need to find the maximum value among all rotations. What I learned: How array rotation works Optimizing brute force using maths Using previous rotation result to calculate the next one efficiently Optimized Approach: Time Complexity: O(n) Space Complexity: O(1) Consistency + daily practice = improvement #LeetCode #DSA #Java #ProblemSolving #CodingJourney #DailyChallenge #LeetCodeDaily
To view or add a comment, sign in
-
-
🚀 Day 5 of #LeetCode Challenge 🔍 Problem: Minimum Distance Between Three Equal Elements I 💡 Approach: Used a brute-force approach with three nested loops to check all possible triplets (i, j, k). Checked if nums[i] == nums[j] == nums[k] Calculated distance using: |i - j| + |j - k| + |k - i| Tracked the minimum distance using Math.min() 🧠 Key Concept: Understanding triplet traversal and applying absolute distance formula. 🔥 #Day5 #LeetCode #Java #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 22/100 — LeetCode Today’s problem: Happy Number 😊 At first, it looked like a simple math problem… but it turned out to be about patterns and repetition. 🔍 What I learned: Break a number into digits using % 10 and / 10 Square each digit and keep adding Repeat the process until: You reach 1 → Happy Number ✅ Or it starts repeating → Not Happy ❌ 🧠 Key Insight: This problem is actually about cycle detection — if a number repeats, it will never reach 1. ⚡ Simple Example: 19 → 82 → 68 → 100 → 1 ✅ 💡 Takeaway: Sometimes problems that look like math are really about loops and patterns. Small steps every day → Big improvement 🚀 #Day22 #100DaysOfCode #LeetCode #Java #DSA #CodingJourney
To view or add a comment, sign in
-
-
🔥 Day 58 of DSA Journey Solved the classic 3Sum (LeetCode 15) problem today. 💡 Key Learnings: Sorting simplifies the problem structure Fix one element and apply the two-pointer approach Handling duplicates correctly is crucial to avoid redundant results ⏱️ Complexity: Time: O(n²) Space: O(1) (excluding output) 📊 Result: Runtime: 33 ms (Beats 73.75%) Strengthened understanding of two-pointer pattern This problem reinforced an important pattern: 👉 Reduce 3Sum → 2Sum using two pointers On to the next challenge 🚀 #DSA #LeetCode #CodingJourney #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 70 — LeetCode Practice ✅ Problem Solved: Minimum Operations to Make Array Sum Divisible by K 💡 What I learned today: • Understood how modulus (%) helps in solving optimization problems • Learned that instead of performing operations repeatedly, we can directly use math logic • Realized that the answer depends on sum % k • Improved thinking towards efficient (O(n)) solutions 📊 Approach: • Calculated total sum of the array • Found remainder using sum % k • That remainder itself gives the minimum operations required 🎯 Key Insight: Sometimes, problems look complex but can be solved using simple mathematical observations instead of brute force 🔥 Consistency is the key — showing up every day! #Day70 #LeetCode #DSA #CodingJourney #ProblemSolving #Consistency #Java
To view or add a comment, sign in
-
-
🚀 Day 33 of #128DaysOfCode 🧩 Problem Insight: The goal was to check whether a given string can be formed by repeating one of its substrings multiple times. 💡 Key Learning: Instead of checking all possible substrings (which can be inefficient), I learned an elegant trick: By concatenating the string with itself and removing the first and last characters, we can determine if the original string exists within it. ⚡ This approach helped me: - Improve my understanding of string patterns - Learn a smart optimization technique - Avoid brute-force solutions 🛠️ Concepts Practiced: - String manipulation - Pattern recognition - Optimized problem-solving approach 📈 Every day I’m getting better at identifying patterns and writing cleaner, more efficient code. #Day33 #128DaysOfCode #Java #DSA #CodingJourney #ProblemSolving #LeetCode
To view or add a comment, sign in
-
-
Solved the Flatten a Multilevel Doubly Linked List problem using iterative pointer manipulation. The idea is to traverse the list, and whenever a node has a child, we attach the child list in between the current node and its next node. Then we find the tail of the child list and connect it back to the original next node. This way, we flatten the list in-place without using extra space. Time Complexity: O(n) Space Complexity: O(1) #Java #DSA #LinkedList #LeetCode #Coding
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development