🚀 Day 46 of My DSA Journey Today I solved a problem that looked simple but had an interesting twist — constrained swapping in strings. 🔍 Problem: Check if two strings can be made equal using swaps where the index difference is exactly 2. 💡 Key Learning: Instead of actually performing swaps, I understood that: Only specific indices can interact (0↔2 and 1↔3) This divides the string into independent groups We just need to compare characters within these groups ✨ This problem reinforced an important concept: 👉 When operations are restricted, think in terms of groups rather than brute-force simulation. #DSA #ProblemSolving #Java #CodingJourney #Consistency #LeetCode
Constrained String Swaps Problem Solved with Grouping Strategy
More Relevant Posts
-
📊 DSA Progress Update – Week 5 Over the past few days, I’ve been practicing array problems and improving my approach step by step. What I learned: • Starting with a brute force solution helps in understanding the problem clearly • Optimization becomes easier once the pattern is identified • Key techniques : - Two Pointers - Sliding Window - Prefix Sum - Kadane’s Algorithm Something new: Started learning Binary Search and understanding its basic approach. Plan: Continue practicing and get more comfortable with these concepts. Taking it one step at a time. #DSA #Java #LeetCode #Consistency #CodingJourney
To view or add a comment, sign in
-
🔥 DSA Challenge – Day 135/360 🚀 📌 Topic: Bit Manipulation 🧩 Problem: Check if a Number is Power of 2 Problem Statement: Given an integer n, determine whether it is a power of 2 or not. 🔍 Example: Input: n = 4 Output: true Input: n = 6 Output: false 💡 Approach: Optimized (Bit Manipulation) 1️⃣ Step 1 – If n <= 0, return false (powers of 2 are always positive) 2️⃣ Step 2 – Use bit trick: n & (n - 1) removes the lowest set bit 3️⃣ Step 3 – If result becomes 0, then only one set bit was present ✔ This avoids looping and works in constant time ⏱ Complexity: Time: O(1) Space: O(1) 📚 Key Learning: A number is a power of 2 if it has exactly one set bit in binary representation. #DSA #Java #Coding #InterviewPrep #ProblemSolving #TechJourney #135DaysOfCode #BitManipulation #LeetCode
To view or add a comment, sign in
-
-
🚀 Day 31/200 – DSA Journey Solved: Contains Duplicate (LeetCode) 🔍 Approach Used: - Sorted the array - Compared adjacent elements - If nums[i] == nums[i-1], duplicate exists ⚡ Complexity: - Time: O(n log n) - Space: O(1) 💡 Key Learning: Brute force approach (O(n²)) is simple but not efficient. Using sorting helps optimize the solution and reduces time complexity. 📈 Progress Insight: Learning to move from brute force to optimized solutions step by step. Consistency > Motivation #DSA #LeetCode #Java #ProblemSolving #CodingJourney #SoftwareEngineering
To view or add a comment, sign in
-
-
🔥 DSA Challenge – Day 136/360 🚀 📌 Topic: Bit Manipulation 🧩 Problem: Number of 1 Bits (Hamming Weight) Problem Statement: Given an integer, return the number of set bits (1’s) present in its binary representation. 🔍 Example: Input: 6 Output: 2 Explanation: Binary of 6 → 110 → 2 set bits 💡 Optimized Approach (Brian Kernighan’s Algorithm): Instead of checking each bit one by one, we use a smart trick: n & (n - 1) removes the rightmost set bit in each iteration This reduces the number of operations to the number of set bits only ⚡ Time Complexity: O(k) (k = number of set bits) ⚡ Space Complexity: O(1) 🚀 Key Takeaway: Using bit manipulation can drastically optimize performance compared to brute force approaches. Always look for patterns in binary operations! #DSA #Coding #Java #BitManipulation #136DaysOfCode #LeetCode #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 59 of DSA Journey 🚀 Solved Largest Rectangle in Histogram (LeetCode 84) — a problem that looks simple but demands real pattern recognition. 💡 Key Takeaways: • Monotonic Stack is 🔑 • Focus on nearest smaller elements • Think in terms of boundaries, not brute force ⚡ Complexity: O(n) time | O(n) space 📊 Result: 71 ms | Beats 38.67% Learning > Performance. Improving daily. 💪 #DSA #LeetCode #Java #100DaysOfCode #Consistency #ProblemSolving
To view or add a comment, sign in
-
-
DSA Practice Update Today I solved: #141 – Linked List Cycle Learned how to detect a cycle in a linked list using Floyd’s Cycle Detection Algorithm (fast and slow pointers). Understood how moving pointers at different speeds helps identify if a loop exists without using extra space. Key Learnings: • Fast and slow pointer technique • Detecting cycles efficiently in O(n) time • Solving problems with constant space complexity This problem strengthened my understanding of pointer-based approaches, which are commonly used in linked list interview questions. Continuing to stay consistent and improve problem-solving skills step by step. #DSA #LeetCode #CodingJourney #Java #SoftwareDevelopment #PlacementPreparation
To view or add a comment, sign in
-
-
🚀 DSA Journey Update: 7/75 Solved another problem today: Product of Array Except Self 💡 Key Idea: Used prefix (left) and suffix (right) products to build the answer without using division and in O(n) time. 🔍 Example: Input: [1,2,3,4] Output: [24,12,8,6] ⚡ Learning: Optimized approach using two passes Space optimization by reusing the same array Stronger understanding of prefix/suffix patterns Step by step progress… consistency matters more than speed 🔥 #DSA #Java #LeetCode #CodingJourney #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 15 of My DSA Journey Today’s problem: Array Rank Transform 💡 Problem Insight: Given an array, replace each element with its rank when the array is sorted. Rank starts from 1 Equal elements → same rank Ranks must be continuous (no gaps) 🧠 Approach: 🔹 Clone and sort the array 🔹 Use a HashMap to assign ranks to unique elements 🔹 Traverse original array and replace values using the map ⚡ Key Learning: 👉 This is a classic example of Coordinate Compression 👉 Helps reduce large values into a smaller ranked range 💻 Code Logic: Sort copy of array Assign rank only if element not already mapped Replace original values using the map 📊 Result: ✅ 43 / 43 test cases passed ⏱ Runtime: 31 ms 📈 Beat: 58.58% 💾 Memory: 74.74 MB (85.14% better than others) 💭 Takeaway: Simple problems can test clean thinking + handling duplicates properly. Hashing + sorting is a powerful combo 🔥 🔥 Consistency Check: Day 15 Complete Building discipline one problem at a time. #DSA #CodingJourney #LeetCode #Java #ProblemSolving #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 57 of DSA Journey Solved Next Greater Element II (LeetCode 503) today — a solid problem on Monotonic Stack + Circular Array concepts. 🔍 Key Learnings: • How to use a monotonic decreasing stack efficiently • Handling circular arrays using 2*n traversal • Understanding when and why elements get resolved in stack-based problems 💡 Insight: This problem reinforced that many questions are just variations of the same core pattern. Once you truly understand the pattern, solving similar problems becomes much more intuitive. 📈 Progress > Perfection. Staying consistent and focusing on building strong fundamentals. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 19/100 — #100DaysOfLeetCode Back to mastering one of the most powerful patterns in DSA — Sliding Window 💻🔥 ✅ Problem Solved: 🔹 LeetCode 1358 — Number of Substrings Containing All Three Characters 💡 Concept Used: Sliding Window + Frequency Tracking 🧠 Key Learning: The goal was to count all substrings containing 'a', 'b', and 'c'. Instead of checking every possible substring, I learned how: Expand the window until all required characters are present. Once valid, every further extension also forms valid substrings. Count substrings efficiently while shrinking the window. This converts a brute-force O(n²) approach into an optimized O(n) solution. ⚡ Big Insight: Sliding Window isn’t just about finding length — it can also be used for counting valid substrings efficiently. Consistency is slowly turning patterns into instincts 🚀 #100DaysOfLeetCode #LeetCode #DSA #SlidingWindow #Algorithms #Java #ProblemSolving #CodingJourney #LearningInPublic #Consistency
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