✅ Day 33 – LeetCode Practice Problem: Rotate String (LeetCode 796 | Easy) Today I worked on string manipulation and pattern recognition by solving LeetCode 796: Rotate String. 🔍 Key Insight: To check if goal is a rotation of s, I learned that if goal is found inside (s + s), then s can be rotated to become goal! This simple trick avoids brute force and makes the solution clean and efficient. 💡 What I practiced: • String concatenation • Pattern matching • Efficient problem approach 📌 Time Complexity: O(n) 📌 Space Complexity: O(n) 🚀 Feeling good about strengthening my string problem skills today! #100DaysOfCode #LeetCode #CodingPractice #Java #StringAlgorithms
Mastanvali Shaik’s Post
More Relevant Posts
-
🚀 Day 3 – LeetCode Practice Today, I solved the 3Sum problem on LeetCode: 🎯 Difficulty: Medium/Hard 💻 Language Used: Java 💡 Approach: • Given an integer array nums, the objective was to find all unique triplets that sum up to zero. • I sorted the array first to simplify searching and avoid duplicates. • Used a fixed pointer + two-pointer technique: – For each element (as the first of the triplet), used two pointers to find pairs that complete the sum to zero. • To avoid duplicate triplets, I skipped repeated values during iteration. ⏱ Complexity: • Time Complexity: O(n²) • Space Complexity: O(1) (excluding output list) 📚 Key Takeaway: This problem strengthened my understanding of sorting combined with two-pointer strategies to reduce brute-force complexity. Handling duplicates correctly was also key to returning unique triplets. Consistent problem-solving practice continues to improve my algorithmic thinking and confidence in handling array-based challenges. 💪 #LeetCode #Java #DSA #TwoPointers #Arrays #ProblemSolving #Algorithms #100DaysOfCode #SoftwareDeveloper
To view or add a comment, sign in
-
-
Day 2/100 – LeetCode Challenge 🚀 Problem: #48 Rotate Image Difficulty: Medium Language: Java Approach: In-Place Rotation using Transpose + Row Reversal Time Complexity: O(n²) Space Complexity: O(1) 🔍 Key Insight: To rotate a matrix 90° clockwise without extra space: 1️⃣ First transpose the matrix (swap across diagonal). 2️⃣ Then reverse each row. This avoids creating a new matrix and satisfies the in-place constraint. 🧠 Solution Brief: Used nested loops to transpose the matrix by swapping arr[i][j] and arr[j][i]. Then reversed each row using two pointers (start and end). Combined both operations inside a rotate() method. Achieved full rotation with constant extra space. 📌 What I Learned: Matrix problems are more about pattern recognition than brute force. Understanding transformations (transpose + reverse) makes complex problems simple. Starting my 100 Days of LeetCode journey today 💪 Consistency > Motivation. #LeetCode #Day2 #100DaysOfCode #Java #DSA #Matrix #ProblemSolving #CodingJourney #MediumProblem
To view or add a comment, sign in
-
-
🔥 Day 513 of #750DaysofCode 🔥 LeetCode 1461 | Check If a String Contains All Binary Codes of Size K Today’s problem was a really interesting mix of strings + hashing + sliding window + bit manipulation. 🧠 Problem Summary: Given a binary string s and an integer k, return true if every possible binary code of length k exists as a substring of s. For example: Input: s = "00110110", k = 2 All possible binary codes of size 2 → "00", "01", "10", "11" Since all exist → ✅ true 💡 Key Insight For length k, total possible binary codes = 2^k So instead of generating all binary codes explicitly, we: Slide a window of size k across the string Store each substring in a HashSet If set.size() == 2^k, we return true ⚡ Optimized Thinking Since: k <= 20 2^20 = 1,048,576 We can also use: Rolling hash Bitmask technique Integer encoding instead of substring creation 🎯 What I Learned Today ✔ Instead of generating all combinations, track what appears ✔ Bitmasking can optimize substring problems ✔ Sliding window + hashing is powerful for pattern coverage problems ✔ Always check constraints before choosing brute force Consistency > Motivation 💪 Onwards to Day 514 🚀 #750DaysOfCode #LeetCode #Java #DSA #CodingJourney #BitManipulation #SlidingWindow
To view or add a comment, sign in
-
-
#Day32 of #365DaysOfCode Today’s LeetCode Practice: 🔹 Container With Most Water (LeetCode 11) Solved a classic two-pointer optimization problem where the goal is to find two lines that together form a container holding the maximum water. 💡 Key Insight: Start with two pointers at both ends. Calculate area using: width × min(height[left], height[right]) Move the pointer with the smaller height inward, because the smaller height limits the water capacity. This guarantees exploring better possibilities efficiently. ⏱ Time Complexity: O(n) 📦 Space Complexity: O(1) Consistency > Motivation. Day by day, improving problem-solving and logical thinking skills #LeetCode #ProblemSolving #Java #CodingJourney #FutureEngineer #Consistency #LearningEveryday
To view or add a comment, sign in
-
-
🚀 Day 5 – LeetCode Practice Today, I solved the Reverse Nodes in k-Group problem on LeetCode: 🎯 Difficulty: Hard 💻 Language Used: Java 💡 Approach: • Given a linked list and an integer k, the task was to reverse every group of k nodes. • I used pointer manipulation and a dummy node to handle group reversals cleanly. • Moved through the list in blocks of k, reversing each sub-group by re-wiring next pointers. • Ensured that if the final group had fewer than k nodes, it was kept as-is. • This approach ensured in-place reversal without extra space. ⏱ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) 📚 Key Takeaway: This problem deepened my understanding of in-place linked list manipulation, group operations, and edge-case handling when list length isn’t a multiple of k. Solving pattern-rich, hard problems like this consistently improves my algorithmic thinking and implementation precision. 💪 #LeetCode #Java #DSA #LinkedList #ProblemSolving #Algorithms #CodingPractice #100DaysOfCode #SoftwareDeveloper
To view or add a comment, sign in
-
-
Leetcode Problem || Sort Integers by Number of 1 Bits (1356)🚀 Today I worked on a problem where we sort integers based on: 1️⃣ Number of set bits in binary representation 2️⃣ If equal, sort by numerical value 💡 Learned: How comparator chaining works Importance of object boxing in Java sorting Clean way to handle multi-level sorting #Java #DSA #LeetCode #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 3 – LeetCode Practice Today, I solved the Container With Most Water problem on LeetCode: 🎯 Difficulty: Medium 💻 Language Used: Java 💡 Approach: • Given an array of heights, the task was to find two lines that form a container holding the maximum amount of water. • Instead of checking all pairs (O(n²)), I used the two-pointer technique to optimize the solution. • Initialized two pointers at both ends of the array. • Calculated the area using the smaller height and distance between pointers. • Moved the pointer at the shorter height inward to potentially find a larger area until both pointers met. ⏱ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) 📚 Key Takeaway: This problem reinforced the power of the two-pointer strategy for optimizing performance and reducing unnecessary computations. Consistent problem-solving practice helps me improve my intuition and efficiency with important algorithmic techniques. 💪 #LeetCode #Java #DSA #TwoPointers #Algorithms #ProblemSolving #100DaysOfCode #SoftwareDeveloper
To view or add a comment, sign in
-
-
Day 44 - LeetCode Journey Solved LeetCode 917: Reverse Only Letters in Java ✅ A clean two-pointer problem that really tests your understanding of string manipulation. The goal was simple: reverse only the letters while keeping all non-letter characters in their original positions. Instead of creating extra data structures, I used two pointers from both ends. If a character is not a letter, we skip it. When both pointers land on letters, we swap them. This continues until the pointers meet. What I liked about this problem is how it teaches you to control movement smartly rather than brute forcing the solution. Key takeaways: • Two-pointer technique for efficient traversal • Handling edge cases (symbols, numbers) • Writing in-place logic without extra space • Clean and readable code ✅ All test cases passed ✅ 100% runtime performance Problems like this improve your thinking for real interview scenarios where optimization matters. #LeetCode #DSA #Java #Strings #TwoPointers #Algorithms #ProblemSolving #CodingJourney #InterviewPrep #Consistency
To view or add a comment, sign in
-
-
🚀 Day 5 – LeetCode Practice Today, I solved the Swap Nodes in Pairs problem on LeetCode: 🎯 Difficulty: Medium 💻 Language Used: Java 💡 Approach: • Given a linked list, the task was to swap every two adjacent nodes and return the modified list. • I used pointer manipulation to iterate through the list. • Maintained a dummy node to handle swaps at the head cleanly. • For each pair, I adjusted the next pointers to reverse the pair and linked them smoothly to the rest of the list. • Continued this process until the end of the list. ⏱ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) 📚 Key Takeaway: This problem reinforced careful linked list traversal and pointer re-wiring for in-place node rearrangement. It’s a great exercise in understanding how to restructure linked lists efficiently. Consistent problem-solving practice continues to sharpen my data structure implementation skills. 💪 #LeetCode #Java #DSA #LinkedList #ProblemSolving #Algorithms #CodingPractice #100DaysOfCode #SoftwareDeveloper
To view or add a comment, sign in
-
-
🚀 Day 6 – LeetCode Practice Today, I solved the Remove Element problem on LeetCode: 🎯 Difficulty: Easy 💻 Language Used: Java 💡 Approach: • Given an integer array nums and a value val, the task was to remove all occurrences of val in-place and return the new length. • I used the two-pointer technique: – One pointer (slow) tracked where to place the next non-val element. – The other pointer (fast) scanned the array from left to right. • When the current element wasn’t equal to val, I copied it to slow and advanced both pointers. • This ensured we overwrote unwanted values and kept the rest in place without extra space. ⏱ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) 📚 Key Takeaway: This problem reinforced in-place modification and efficient array traversal with minimal space. Simple pointer strategies often help optimize brute-force approaches. Consistent problem-solving practice continues to strengthen my fundamentals and coding clarity. 💪 #LeetCode #Java #DSA #TwoPointers #Arrays #ProblemSolving #Algorithms #100DaysOfCode #SoftwareDeveloper
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