🚀 Day 29 of 100 Days LeetCode Challenge Problem: Check if Strings Can be Made Equal With Operations I Day 29 is a short but pattern + constraint observation problem 🔥 💡 Key Insight: We can only swap characters where: 👉 j - i = 2 For a string of length 4, possible swaps: Index 0 ↔ 2 Index 1 ↔ 3 👉 That means: Positions (0,2) form one group Positions (1,3) form another group 🔍 Core Approach: 1️⃣ Group Characters Extract characters from: Even indices → [0, 2] Odd indices → [1, 3] 2️⃣ Compare Groups Sort both groups for s1 and s2 If both corresponding groups match → ✅ true Else → ❌ false 💡 Why This Works: You can rearrange freely within each group But cannot mix between groups 🔥 What I Learned Today: Limited operations define independent groups Think in terms of index grouping Small problems still test logical clarity 📈 Challenge Progress: Day 29/100 ✅ One day to 30! LeetCode, Strings, Swapping, Greedy, Pattern Recognition, Arrays, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #Strings #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
Check if Strings Can be Made Equal With Operations
More Relevant Posts
-
🚀 Day 19 of 100 Days LeetCode Challenge Problem: Count Submatrices With Equal Frequency of X and Y Today’s problem was a solid combination of 2D Prefix Sum + Hashing concept 🔥 💡 Key Insight: We need submatrices that: Include the top-left cell (0,0) Have equal number of 'X' and 'Y' Contain at least one 'X' 👉 Trick: Convert the grid into values: 'X' → +1 'Y' → -1 '.' → 0 🔍 Core Approach: 1️⃣ 2D Prefix Sum Transformation Build prefix sum based on above conversion 2️⃣ Check Each Submatrix (0,0 → i,j) If sum == 0 → equal number of X and Y ✅ 3️⃣ Extra Condition: Ensure at least one 'X' exists 👉 Track X count separately using another prefix matrix 🔥 What I Learned Today: Transforming problems into numbers simplifies logic Prefix sums + condition checks = powerful combo Always handle extra constraints carefully 📈 Challenge Progress: Day 19/100 ✅ Almost hitting Day 20! LeetCode, Prefix Sum, Matrix, Hashing, Problem Transformation, Algorithms, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #PrefixSum #Matrix #Hashing #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
🚀 Day 14 of 100 Days LeetCode Challenge Problem: The K-th Lexicographical String of All Happy Strings of Length n Today’s problem is a perfect blend of Backtracking + Lexicographical Ordering 🔥 💡 Key Insight: A happy string: Uses only 'a', 'b', 'c' No two adjacent characters are the same 👉 Instead of generating all strings blindly, we: Build valid strings using backtracking Maintain lexicographical order naturally 🔍 Core Approach: 1️⃣ Backtracking (DFS) Start building string character by character At each step: Choose from 'a', 'b', 'c' Skip if same as previous character 2️⃣ Lexicographical Order Always try characters in order: 'a' → 'b' → 'c' 3️⃣ Stop Early Once we reach the k-th string, stop recursion 👉 If total strings < k → return "" 🔥 What I Learned Today: Backtracking is powerful for constraint-based generation Ordering decisions early helps avoid extra sorting Early stopping = major optimization 📈 Challenge Progress: Day 14/100 ✅ 2 weeks strong! LeetCode, Backtracking, Recursion, Lexicographical Order, Strings, DFS, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #Backtracking #Recursion #Strings #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
🚀 Day 23 of 100 Days LeetCode Challenge Problem: Maximum Non-Negative Product in a Matrix Today’s problem was a deep dive into Dynamic Programming with edge cases (negative values) 🔥 💡 Key Insight: Since the grid contains negative numbers, the product can flip sign. 👉 So at each cell, we must track: Maximum product so far Minimum product so far Because: Negative × Negative = Positive 💥 🔍 Core Approach (DP): 1️⃣ DP State: For each cell (i, j) maintain: maxProduct[i][j] minProduct[i][j] 2️⃣ Transition: From top (i-1, j) and left (i, j-1): Multiply current value with both max & min Take: max → for maxProduct min → for minProduct 3️⃣ Final Answer: If final max ≥ 0 → return max % (10⁹ + 7) Else → return -1 🔥 What I Learned Today: Negative values require tracking both extremes DP is not always just “max”—sometimes it’s min + max together Edge cases define the real difficulty of a problem 📈 Challenge Progress: Day 23/100 ✅ Getting stronger with DP! LeetCode, Dynamic Programming, Matrix, Optimization, Negative Numbers, Algorithms, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #DynamicProgramming #Matrix #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
Day 77 on LeetCode Find Smallest Letter Greater Than Target 🔤🔍✅ Continuing the streak with a clean Binary Search application — keeping things simple and consistent during mids 💯 🔹 Approach Used in My Solution The goal was to find the smallest character strictly greater than the target in a sorted array, with wrap-around behavior. Key idea: • Apply binary search on the sorted array • Whenever letters[mid] > target, store it as a potential answer • Move left to find an even smaller valid character • If no such character exists, return letters[0] (wrap-around case) This ensures we always get the next greatest letter efficiently. ⚡ Complexity: • Time Complexity: O(log n) • Space Complexity: O(1) 💡 Key Takeaways: • Practiced binary search for “next greater element” problems • Learned how to handle wrap-around edge cases • Reinforced writing clean and optimized search logic 🔥 Small wins every day consistency is the real progress. #LeetCode #DSA #Algorithms #DataStructures #BinarySearch #Arrays #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #Consistency #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
I spent 30 minutes overthinking a problem that had a 2-minute solution. Problem: Construct Uniform Parity Array I At first, it feels like a construction + constraints problem. You start thinking about cases, patterns, edge conditions… But then I stepped back and looked at the operations: nums2[i] = nums1[i] nums2[i] = nums1[i] - nums1[j] (j ≠ i) Now ask a better question: 👉 What happens to parity under these operations? Same value => parity unchanged Difference of two numbers => can be even or odd depending on choice That’s the key. You can control parity freely. Just to make the entire array all even or all odd And that’s always possible. So the answer would be always TRUE . #FirstPrinciples #ProblemSolving #CodingJourney #LeetCode #DSA #Algorithms #SoftwareEngineering #Developers #CodeNewbie #LearnToCode #ProgrammingLife #TechThinking #LogicalThinking #BuildInPublic #DeveloperMindset #CleanThinking #CodingLife #TechCareers #GrowthMindset #ThinkDifferent
To view or add a comment, sign in
-
-
Day 81 on LeetCode Remove Linked List Elements 🔗🧹✅ Still prioritizing consistency during busy days — and today’s problem was a solid linked list traversal & deletion practice 💯 🔹 Approach Used in My Solution The goal was to remove all nodes with a given value from a linked list. Key idea: • First, handle edge cases where head itself contains the target value • Move head forward until it points to a valid node • Then traverse the list using two pointers: – prev → last valid node – temp → current node • If temp->val == val → skip the node by linking prev->next • Otherwise → move both pointers forward This ensures all matching nodes are removed efficiently. ⚡ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) 💡 Key Takeaways: • Practiced pointer manipulation in linked lists • Learned how to safely handle deletions, especially at head • Reinforced importance of edge case handling 🔥 Small consistent steps → strong fundamentals. #LeetCode #DSA #Algorithms #DataStructures #LinkedList #Pointers #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #Consistency #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Day 88 on LeetCode Add Two Numbers 🔗➕💡 A classic linked list problem focusing on digit-wise addition with carry handling. 🔹 Approach Used in My Solution • Traverse both linked lists simultaneously • Maintain a carry variable for overflow • Add corresponding node values + carry • Create new nodes for result using a dummy head • Continue until both lists and carry are fully processed ⚡ Complexity: • Time Complexity: O(max(n, m)) • Space Complexity: O(max(n, m)) 💡 Key Takeaways: • Dummy node simplifies linked list construction • Carry handling is the core concept in this problem • Reinforces simulation of real-world arithmetic using linked lists 🔥 Another step forward in strengthening pointer-based problem solving. #LeetCode #DSA #Algorithms #DataStructures #LinkedList #AddTwoNumbers #CarryLogic #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #Consistency #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Day 80 on LeetCode Next Greater Element I 🔍📈✅ Not the optimal solution this time, but the focus remains the same consistency over perfection 💯 🔹 Approach Used in My Solution (Brute Force) The goal was to find the next greater element of each value in nums1 based on its position in nums2. Key idea: • For each element in nums1 → find its position in nums2 • From that index, scan to the right • The first element greater than current → that’s the answer • If none found → return -1 A straightforward approach that gets the job done. ⚡ Complexity: • Time Complexity: O(n * m) • Space Complexity: O(1) (excluding output) 🔹 Optimal Insight (For Next Time) • Use a monotonic decreasing stack on nums2 • Precompute next greater for all elements • Store results in a hash map for O(1) lookup 💡 Key Takeaways: • Even brute force builds understanding of the problem • Learned how nested traversal simulates next greater search • Not every day is about optimization — discipline matters more 🔥 Streak > Speed. Showing up daily is the real win. #LeetCode #DSA #Algorithms #DataStructures #Stack #MonotonicStack #Arrays #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #Consistency #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
🚀 340+ LeetCode Problems Solved What started as random problem solving has now become a consistent habit. I’ve crossed 340+ problems on LeetCode, and more importantly, improved how I approach problems. Breakdown: • Easy: 144 • Medium: 182 • Hard: 14 Key lessons from this journey: • Consistency beats intensity — even 2–3 problems daily compounds over time • Struggling is part of the process — the real learning happens when you don’t get it immediately • Patterns matter more than problems — recognizing approaches (DP, Graphs, Sliding Window) is key • Revisiting problems is underrated — solving once is not enough • Clean thinking > fast coding — clarity leads to optimal solutions This journey has helped me build: • Strong problem-solving skills • Better debugging and analytical thinking • Confidence in tackling interview-level questions Next target: 500+ problems 💯 Let’s keep building 🚀 #LeetCode #DSA #CodingJourney #SoftwareEngineering #Placements2026
To view or add a comment, sign in
-
-
“Hard” doesn’t always mean complex logic. Today I solved the Text Justification problem on LeetCode. And it taught me something unexpected. At first glance, it looks like one of those problems where you need some crazy algorithm. But that wasn’t the real challenge. The logic? Pretty straightforward. The real difficulty was something else entirely: → Structuring the output → Handling edge cases → Distributing spaces correctly → Staying patient when everything almost works It wasn’t about intelligence. It was about discipline. Line by line. Case by case. That’s when it hit me: Some “hard” problems aren’t hard because of logic… They’re hard because they test your patience and precision. And honestly, that’s a different kind of skill. If you’re stuck on a problem like this, don’t just think harder. Think calmer. Break it down. Control the structure. And keep going. Have you faced a problem that wasn’t logically hard, but mentally exhausting? Drop it below 👇 #leetcode #dsa #programming #coding #softwareengineering #problemsolving #algorithms #codingjourney #growthmindset #patience #consistency #developers #csstudents
To view or add a comment, sign in
-
Explore related topics
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