🧩 Day 64 of #100DaysOfCode 🧩 🔹 Problem: Remove All Adjacent Duplicates in String – LeetCode ✨ Approach: Used a stack-based approach to efficiently remove adjacent duplicates. For each character, if it matches the stack’s top element, pop it — otherwise, push it. A simple yet powerful way to process strings in O(n) time while maintaining clean logic. ⚡ 📊 Complexity Analysis: Time Complexity: O(n) — each character is processed once Space Complexity: O(n) — for the stack and output string ✅ Runtime: 23 ms (Beats 54.52%) ✅ Memory: 45.26 MB (Beats 85.43%) 🔑 Key Insight: Sometimes, solving problems isn’t about brute force — it’s about using the right data structure to make every step count. 💡 #LeetCode #100DaysOfCode #ProblemSolving #DSA #Stack #StringManipulation #CleanCode #CodingChallenge #AlgorithmDesign #LogicBuilding #CodeJourney #Programming
"Day 64: Stack-based solution for LeetCode string problem"
More Relevant Posts
-
🚀 Today I practiced one of the most important Linked List problems — Sorting a Linked List efficiently. Instead of converting the list into an array (which increases extra memory usage), I implemented Merge Sort directly on the linked list. 🔍 Why Merge Sort for Linked List? Linked lists don’t have random indexing. Merge Sort works naturally by rearranging pointers. No need of extra space for arrays. 🎯 Result: Time Complexity: O(n log n) Space Complexity: O(log n) due to recursion Stable & Clean Solution 💡 What I learned: Using slow–fast pointer technique to find the middle of the list. Splitting the linked list into two halves efficiently. Merging two sorted linked lists without extra memory. Writing cleaner, structured logic improves readability a LOT. Everyday small progress really compounds. Trying to solve at least one challenge daily 💪 #ConsistencyWins #leetcode #dsa #linkedlist #algorithms #programming #cpp #softwareengineering #codingjourney #learningeveryday #100daysofcode
To view or add a comment, sign in
-
-
On Day 295 of my #300daysofcode challenge, I'm sharing my solution to LeetCode Problem 981, "Time Based Key-Value Store." This problem requires designing a specialized data store for version control. My video provides a clear walkthrough of the optimal design: using a HashMap to quickly find the key and then applying Binary Search on the timestamps to retrieve the correct historical value. This is a valuable skill for advanced data structure implementation and system design interviews. #DataStructures #Algorithms #LeetCode #CodingInterview #Programming #SystemDesign #300daysofcode
To view or add a comment, sign in
-
🚀 LeetCode POTD — 2536. Increment Submatrices by One 🎯 Difficulty: Medium | Topics: 2D Difference Array, Prefix Sums, Matrix Manipulation 🔗 Solution Link: https://lnkd.in/gpjg6t5w Today’s #LeetCode Problem of the Day was a classic 2D difference array question — simple once you recognize the pattern, but extremely efficient compared to brute-force updates. We’re given an n × n zero matrix and multiple queries, where each query asks us to increment every element in a submatrix by 1. Updating each cell one-by-one would be too slow, so difference-array logic makes the solution clean and optimal. 🧠 My Approach: For each query [x, y, a, b], instead of updating the entire submatrix, update only the start and end boundaries using difference marks: matrix[i][y] += 1; if (b + 1 < n) matrix[i][b + 1] -= 1; Loop from row x to a and apply these boundary updates. After processing all queries, run a prefix sum row-wise to build the final matrix. This reduces the complexity drastically and leverages the power of prefix operations. 📈 Complexity: Time: O(n² + q × submatrix_height) Space: O(n²) 💡 Takeaway: Difference arrays (1D or 2D) are among the most elegant techniques to convert repeated updates into boundary operations — a pattern that appears often in competitive programming and system-level problems. #LeetCode #ProblemOfTheDay #DSA #Matrix #PrefixSum #DifferenceArray #CodingChallenge #Programming #SoftwareEngineering #CodingJourney #100DaysOfCode #TechCommunity
To view or add a comment, sign in
-
-
💻 Day 34 of #100DaysOfLeetCode Today’s Challenge: 83. Remove Duplicates from Sorted List 🔹 Problem: Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. Key Insight: Because the list is already sorted, duplicates will always be adjacent—this allows us to remove them in a single pass using pointer manipulation. 🔍 Approach: Traverse the list using a pointer. Compare current node with the next node. If values are equal → skip the next node by linking to the next of next. Otherwise → move forward. 🕒 Time Complexity: O(n) 📦 Space Complexity: O(1) ✨ Key Takeaway: This problem reinforces the importance of pointer manipulation and understanding how memory references work in linked lists. A simple check can eliminate duplicates efficiently without using extra space. Link:[https://lnkd.in/gsjVxHXM] #100DaysOfLeetCode #Day34 #LeetCode #ProblemSolving #DSA #Algorithms #LinkedList #CodingChallenge #CodeNewbie #InterviewPreparation #SoftwareEngineering #Programming #CodingCommunity #TechCareers #CareerGrowth #ArjunInfoSolution
To view or add a comment, sign in
-
-
🚀 C TIP OF THE DAY: Meet the “#” you never knew existed! It’s not a comment, it’s STRINGIFICATION—the preprocessor’s magic wand that turns your code INTO a string literal. Why care? Zero-cost debug prints: LOG(error) → logs "error" No-duplication name+string tables Build DSLs/configs without leaving C Code: #define STR(x) #x #define XSTR(x) STR(x) #define VERSION 42 puts(STR(VERSION)); // "VERSION" puts(XSTR(VERSION)); // "42" #define LOG(tag) puts(#tag) LOG(error); // "error" Tip: STR() stringifies tokens as written; XSTR() expands first, then stringifies. Next time you’re copying token names into strings, #-it instead and let the compiler do the typing. Save this post for the next code review—and share the #PreprocessingLove! #CProgramming #Preprocessor #CodingTips #SoftwareDevelopment #Programming #TechTips #CodeOptimization
To view or add a comment, sign in
-
-
Stringification is such an underrated feature in C—turning tokens into strings opens up so many clever uses for logging and configs. C really runs deep.
🚀 C TIP OF THE DAY: Meet the “#” you never knew existed! It’s not a comment, it’s STRINGIFICATION—the preprocessor’s magic wand that turns your code INTO a string literal. Why care? Zero-cost debug prints: LOG(error) → logs "error" No-duplication name+string tables Build DSLs/configs without leaving C Code: #define STR(x) #x #define XSTR(x) STR(x) #define VERSION 42 puts(STR(VERSION)); // "VERSION" puts(XSTR(VERSION)); // "42" #define LOG(tag) puts(#tag) LOG(error); // "error" Tip: STR() stringifies tokens as written; XSTR() expands first, then stringifies. Next time you’re copying token names into strings, #-it instead and let the compiler do the typing. Save this post for the next code review—and share the #PreprocessingLove! #CProgramming #Preprocessor #CodingTips #SoftwareDevelopment #Programming #TechTips #CodeOptimization
To view or add a comment, sign in
-
-
On Day 302 of the coding journey, I'm sharing my solution to LeetCode Problem 528, "Random Pick with Weight." This problem requires designing a data structure for weighted random selection. My video provides a clear walkthrough of the optimal strategy: using a Prefix Sums array to map weights to cumulative ranges, then performing a fast Binary Search to find the corresponding index. This is a valuable skill for system design and advanced data structure implementation. #DataStructures #Algorithms #LeetCode #CodingInterview #Programming #BinarySearch #PrefixSums
To view or add a comment, sign in
-
On Day 294 of my #300daysofcode challenge, I'm sharing my solution to LeetCode Problem 1146, "Snapshot Array." This problem requires designing a specialized array that efficiently handles updates and historical queries. My video provides a clear walkthrough of the optimal design: using a list of versioned entries per index and then applying Binary Search to query the correct historical state. This is a valuable skill for system design and advanced data structure implementation. #DataStructures #Algorithms #LeetCode #CodingInterview #Programming #SystemDesign #300daysofcode
To view or add a comment, sign in
-
🚀 DSA Progress – Day 99 ✅ Problem #190: Reverse Bits 🧠 Difficulty: Easy | Topics: Bit Manipulation, Binary Representation, Bitwise Operations 🔍 Approach: Implemented a bitwise manipulation method to reverse all 32 bits of an unsigned integer. This problem helps build a strong understanding of how bits can be extracted, shifted, and reassembled — a key concept in low-level programming and embedded systems. Step 1 (Initialization): Start with rev = 0 to store the reversed bits. Step 2 (Extract + Reverse): For each bit position i from 0 to 31: Extract the ith bit using (n >> i) & 1. Move that bit to its reversed position (31 - i) using (bit << (31 - i)). Combine it into rev using bitwise OR (|=). Step 3 (Return Result): After processing all bits, return the reversed number as the final result. 🕒 Time Complexity: O(32) → effectively O(1) (constant time) 💾 Space Complexity: O(1) → no extra data structures used 📁 File: https://lnkd.in/gKeNZQf9 📚 Repo: https://lnkd.in/g8Cn-EwH 💡 Learned: This problem deepened my understanding of bit-level operations like shifting (<<, >>) and masking (&, |). It showed how reversing bits is similar to flipping binary mirrors — a useful concept in embedded systems, graphics, and cryptographic algorithms. The challenge reinforced that mastering bitwise logic is essential for writing efficient, low-level optimized code. ✅ Day 99 complete — flipped every bit, reversed the logic, and came out enlightened! ⚡💡💻 #LeetCode #DSA #Python #BitManipulation #Binary #CodingChallenge #InterviewPrep #100DaysOfCode #DailyCoding #GitHubJourney
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