I’ve been consistently practicing Data Structures & Algorithms, focusing on understanding the underlying logic and core patterns behind each problem rather than just solving them. Here’s a summary of some recent problems I’ve tackled, along with the key concepts learned 📌 225. Implement Stack using Queues Key Concept: Queue-based simulation of stack operations (using two queues or a single optimized queue) https://lnkd.in/gabQrA_R 📌232. Implement Queue using Stacks Key Concept: Stack-based implementation using two stacks — one for enqueue, one for dequeue operations https://lnkd.in/gwq44Akm 📌102. Binary Tree Level Order Traversal Key Concept: Breadth-First Search (BFS) using a queue for level-wise traversal of binary trees https://lnkd.in/gn4ejwNK 📌239. Sliding Window Maximum Key Concept: Deque-based sliding window to efficiently track the maximum element in each window https://lnkd.in/gwDAFZkP 📌435. Non-overlapping Intervals Key Concept: Sorting by end time + greedy interval selection to minimize overlaps https://lnkd.in/gVwP-2pf 📌1710. Maximum Units on a Truck Key Concept: Greedy approach inspired by the knapsack problem — maximize total units by sorting on value https://lnkd.in/gqxdifBu 📌646. Maximum Length of Pair Chain Key Concept: Similar to non-overlapping intervals — greedy selection based on the smallest end time https://lnkd.in/gik6pJ6K These problems helped me strengthen concepts like queue–stack interconversion, BFS traversal, sliding window optimization, greedy algorithms, and interval scheduling techniques. I’d highly recommend trying these problems out — they’re great for building pattern recognition and problem-solving intuition. Here’s my LeetCode Profile for reference: https://lnkd.in/gp38YMN7 #DSA #LeetCode #Java #Algorithms #ProblemSolving #CodingInterview #SoftwareDevelopment #SDE #TechJourney #DailyCoding
Practiced Data Structures & Algorithms with LeetCode problems
More Relevant Posts
-
🚀 Problem-Solving Insight: Finding K Closest Points to the Origin Imagine you’re given a set of points on a 2D plane, and you need to identify which k points are closest to the origin (0, 0). At first glance, it seems like you’d have to calculate the exact Euclidean distance for every point — but that’s unnecessary. Since we only care about comparing distances, the square root part of the formula can be skipped entirely! Here’s the logic breakdown 👇 1️⃣ Compute distance squared For each point (x, y), calculate distance = x² + y². (We skip the square root since it doesn’t change the order of distances.) 2️⃣ Keep track of the closest points Use a data structure like a max heap of size k. As you process each point, push it into the heap. If the heap exceeds size k, remove the farthest point. This ensures the heap always holds the k closest points seen so far. 3️⃣ Extract the result Once all points are processed, the heap contains the k points closest to the origin. This approach reduces complexity from O(n log n) (sorting all points) to O(n log k) — a significant improvement when dealing with large datasets. 💡 Key takeaway: When solving optimization problems, think about what you really need to compare — sometimes avoiding unnecessary operations (like sqrt) can make your algorithm both cleaner and faster. #ProblemSolving #DataStructures #Algorithms #CodingInterview #Java #LeetCode #TechInsights
To view or add a comment, sign in
-
-
🚀 Day 91 of #SridharSolves100 – “Check If Digits Are Equal in String After Operations I” 💡 Problem Insight: Given a numeric string s, we repeatedly replace it with a sequence of sums of consecutive digits modulo 10 — until only two digits remain. If the final two digits are the same, return true; otherwise, false. ✅ Digits are equal → true 💭 Intuition: Think of it like compressing a signal waveform — each reduction step combines adjacent elements until we reach a minimal “frequency signature.” If the last two digits resonate (are equal), the signal stabilizes — otherwise, it diverges. ⚙️ Approach: ==> Convert the string to a list of digits. While length > 2: Replace the list with consecutive (a+b)%10 results. Return true if final digits are equal, else false. 💻 Time Complexity: O(n²) (since each iteration reduces size by 1) 💾 Space Complexity: O(n) 🎯 Real-World Analogy: This is like data aggregation in sensor networks — multiple readings are merged iteratively to reach a single consensus. If the consensus stays stable (equal digits), it indicates consistency; if not, there’s fluctuation (difference in data pattern). 🔗 My Solution: https://shorturl.at/TSRlq 👉 Pro tip: Always watch for “repeated operation until condition” patterns — they hide simulation loops that can be optimized or simplified using math observation. #Java #DataStructures #CodingInterview #Algorithm #StringManipulation #Simulation #ProblemSolving #GreedyApproach #PrefixSum #100DaysOfCode #SridharSolves100 #TechCareer #DSA #LeetCode #CodingChallenge
To view or add a comment, sign in
-
-
🔥 Day 121 of My DSA Challenge – Remove Duplicates from Sorted List 🔷 Problem : 83. Remove Duplicates from Sorted List 🔷 Goal : Given the head of a sorted linked list, remove all duplicate nodes so that each element appears only once, while maintaining the sorted order. 🔷 Key Insight : This problem is a great example of linked list traversal and pointer management. Because the list is already sorted, all duplicates appear consecutively — which makes it easy to detect and skip them in one pass. The challenge is to handle links carefully so that only unique nodes remain connected. 🔷 Approach : 1️⃣ Initialize a dummy node (with a distinct value) to simplify linking. 2️⃣ Use a tail pointer to build a new list containing only unique elements. 3️⃣ Traverse the list using head: If head.val is not equal to the last added node (tail.val), link it. Otherwise, skip the duplicate. 4️⃣ Update tail.next = null at the end to avoid leftover links. 5️⃣ Return dummy.next as the new head. Time Complexity: O(n) Space Complexity: O(1) This problem strengthens concepts of : ✅ Duplicate handling in linked lists ✅ Pointer-based traversal ✅ Clean in-place modification Sometimes, cleaning a data structure is just about connecting only what truly matters. ⚡ Every small pattern makes a big difference in problem-solving clarity. One more concept locked in 💻 #Day121 #DSA #100DaysOfCode #LeetCode #Java #LinkedList #ProblemSolving #Algorithms #DataStructures #CodingChallenge #DeveloperJourney #EngineerMindset #GrowEveryday
To view or add a comment, sign in
-
-
Day 55 of the #90DaysWithDSA challenge is complete! Today was about converting a binary tree into a storable format and reconstructing it perfectly - a fundamental skill for distributed systems and data persistence. Today's Problem: Serialize and Deserialize Binary Tree (LeetCode 297 - Hard) The challenge: Design an algorithm to serialize and deserialize a binary tree. Serialization is converting a tree to a string, and deserialization is reconstructing the exact same tree from that string. This problem uses pre-order traversal with a clever approach to handle null nodes: The Approach: Serialization: Use pre-order traversal (root, left, right), representing null nodes with a special marker (like "X"). This creates a unique string representation. Deserialization: Split the string and use the same pre-order logic to rebuild the tree. Consume nodes from the list, creating nodes for values and handling null markers appropriately. This approach runs in O(n) time for both operations and handles any binary tree structure. Key Takeaway: Tree serialization is crucial for storing tree structures in databases, sending them over networks, or caching. The pre-order traversal with null markers ensures the tree structure is preserved unambiguously. This pattern is used in real-world applications like storing parse trees, game states, and configuration trees. 55 days of consistent coding. Understanding how data structures translate to persistent storage is incredibly valuable! 💡 Let's keep building practical CS skills together! 👉 Want to master data structure serialization and real-world applications? JOIN THE JOURNEY! Comment "Serializing with you!" below and share what practical CS problem you're working on. 👉 Repost this ♻️ to help other developers discover this challenge and learn about data persistence techniques. Where have you encountered serialization in your projects or studies? #Day55 #BinaryTree #Serialization #Deserialization #DataPersistence #CodingInterview #Programming #SoftwareEngineering #Tech #LearnInPublic #Developer #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🔥 Day 122 of My DSA Challenge – Delete Node in a Linked List 🔷 Problem : 237. Delete Node in a Linked List 🔷 Goal : Delete a given node from a singly linked list — but without having access to the head of the list. 🔷 Key Insight : This is one of those classic Linked List interview questions that tests conceptual understanding over coding complexity. Normally, to delete a node, we need access to its previous node (to change the next pointer). But here, we’re not given the head — only the node that must be deleted. So how do we “delete” it? By using a clever trick — 👉 Copy the value of the next node into the current node. 👉 Then skip the next node (effectively deleting it). 🔷 Approach : 1️⃣ Overwrite the current node’s value with the value of its next node. 2️⃣ Link the current node’s next pointer to node.next.next. 3️⃣ This effectively removes the “next” node from the chain, achieving deletion without needing the head reference. Time Complexity: O(1) Space Complexity: O(1) This problem beautifully demonstrates data overwriting and pointer manipulation in linked lists. Sometimes, deleting isn’t about removing — it’s about replacing smartly. ⚡ Concepts reinforced : ✅ In-place modification ✅ Node manipulation ✅ Understanding memory links in Linked Lists Every concept — from arrays to linked lists — builds a deeper sense of logic and problem-solving clarity. #Day122 #DSA #100DaysOfCode #LeetCode #Java #LinkedList #ProblemSolving #Algorithms #DataStructures #CodingChallenge #DeveloperJourney #EngineerMindset #GrowEveryday #Learning
To view or add a comment, sign in
-
-
HashMap / Frequency Map Pattern — A Simple Way to Make Many Problems Easier One of the most helpful patterns in DSA is using a HashMap (or dictionary) to store frequencies, counts, and relationships. It sounds basic, but once you start using it properly, it simplifies a huge number of array and string problems. Many challenges become easier when you track: 1. How many times does something appear 2. whether two elements match 3. whether a pattern exists 4. or which elements you’ve already seen HashMaps help you avoid unnecessary loops and give you instant lookups in O(1) time. Where This Pattern Shines You can use HashMaps to handle: 1. frequency of characters 2. frequency of numbers 3. mapping relationships (like original → index) 4. tracking visited pairs 5. Comparing two strings 6. counting subarrays This tiny tool solves big problems. Examples You Can Try 1. Two Sum (LeetCode 1) https://lnkd.in/dUgJH-Ss Store numbers in a map as you go. Instant complement lookup instead of nested loops. 2. Valid Anagram (LeetCode 242) https://lnkd.in/dzaRRedB Compare frequency maps of both strings. Clear and direct. 3. Top K Frequent Elements (LeetCode 347) https://lnkd.in/dCm6CcDt Count frequencies first, then use a heap/bucket approach. 4. Subarray Sum Equals K (LeetCode 560) https://lnkd.in/d9fWhG7B Prefix sum + frequency map. Efficient and elegant. 5. Group Anagrams (LeetCode 49) https://lnkd.in/dUzJ_kgX Hashing sorted strings or character counts creates natural groups. Why This Pattern Helps Others Too This is one of the easiest patterns to understand, and it gives a huge confidence boost because: • solutions become cleaner • the approach becomes predictable • you stop writing expensive nested loops • and the overall logic feels more organized Once you start spotting places where a HashMap can store helpful data, many “hard” questions suddenly feel manageable. #DSA #CodingPatterns #LeetCode #CodingJourney #LearningInPublic #SoftwareEngineering #ProblemSolving #CleanCode #DeveloperMindset #SDEJourney #TechCommunity
To view or add a comment, sign in
-
🔥 Day 115 of My DSA Challenge – Intersection of Two Arrays II 🔷 Problem : 350. Intersection of Two Arrays II 🔷 Goal : Return the intersection of two arrays, where each element in the result must appear as many times as it shows in both arrays. Order doesn’t matter. 🔷 Key Insight : This is an extension of the previous problem (Intersection of Two Arrays). The twist? Here we need to consider duplicate occurrences too. For example : nums1 = [1,2,2,1], nums2 = [2,2] → result should be [2,2] (because 2 appears twice in both). 🔷 Approach : 1️⃣ Use a HashMap to count occurrences of each element in nums1. 2️⃣ Traverse nums2 and check if an element exists in the map. 3️⃣ If yes → add it to the result and decrease its count in the map. 4️⃣ When the count becomes 0, remove it from the map to keep things clean. Time Complexity: O(n + m) Space Complexity: O(n) This problem strengthens hash-based frequency counting and element tracking. Use a map to record frequency — then match, decrease, and clean up. This logic is key for : ✅ Counting duplicates ✅ Array frequency comparison ✅ Inventory & matching systems Every small concept compounds into bigger problem-solving clarity. Step by step, I’m becoming stronger at thinking like a coder 💪💻 #Day115 #DSA #100DaysOfCode #HashMap #LeetCode #ProblemSolving #Java #CodingChallenge #Algorithms #DataStructures #DeveloperJourney #LogicBuilding #EngineerMindset #GrowEveryday
To view or add a comment, sign in
-
-
Beyond “Green”: Ensuring Semantic Alignment from Code to Warehouse Unit tests guard your code. Pandera guards your data. Aren’t they just two sides of the same coin? Once for code. Once for data. • Unit tests make sure your logic behaves as expected. • Pandera validations make sure your data looks as expected. Different layers, same purpose: ➡️ Ensuring intent survives translation — from code → data → warehouse. They’re not separate tools. They’re reflections of the same semantic pattern. That’s when I realized: Testing and validation are two sides of the same governance system. Together, they form a symmetry 👇 Layer | Tool | What It Guards | Semantic Role -------------|-------------|--------------------------|------------------------ Application | Unit Test | Logic correctness | Behavioral assurance DataFrame | Pandera | Data correctness | Semantic assurance Database | ENUM | Value constraints | Structural assurance Warehouse | dbt Tests | Transform correctness | Systemic assurance And when every layer speaks the same “semantic language”, ✅ no longer means “done” — it means aligned. Full story and diagrams on Medium (link in the first comment) #DataEngineering #DataQuality #SemanticGovernance #SoftwareTesting #SystemDesign #Python #dbt
To view or add a comment, sign in
-
-
💡 Day 114 of My DSA Challenge – Intersection of Two Arrays 🔷 Problem : 349. Intersection of Two Arrays 🔷 Goal : Find the unique common elements between two integer arrays. The order of elements doesn’t matter. 🔷 Key Insight : This is a Hashing-based problem. We need to identify the numbers that appear in both arrays — but each element should appear only once in the result. The idea is simple : 1️⃣ Store all elements of the first array in a HashMap (or HashSet). 2️⃣ Traverse the second array and check for matches. 3️⃣ Whenever a match is found → add it to the result and remove it to avoid duplicates. 🔷 Approach : 1️⃣ Use a HashMap to store unique elements from nums1. 2️⃣ Iterate through nums2, and if an element exists in the map → add it to the result list. 3️⃣ Remove the element from the map after adding (to prevent duplicates). 4️⃣ Convert the result list to an array and return it. Time Complexity: O(n + m) Space Complexity: O(n) 🔷 Takeaway : This problem strengthens hash-based searching and uniqueness handling — Use HashMap / HashSet when you need fast lookups and uniqueness control. ✅ This logic is frequently used in : Duplicate removal problems Union & intersection operations Set theory-based DSA problems ✨ Another simple yet powerful concept mastered. Every small step counts toward building a strong foundation. 💪 #Day114 #DSA #100DaysOfCode #HashMap #HashSet #LeetCode #ProblemSolving #Java #CodingChallenge #Algorithms #DataStructures #DeveloperJourney #LogicBuilding #EngineerMindset
To view or add a comment, sign in
-
-
A good practice for expensive (slow or repeated) computations is to use memoization, which stores the results so that any time they are needed again with the same input, the function instantly returns the cached result instead of redoing the work. talk of Math functions such as Fibonacci, factorial, primes; API calls to avoid repeat network requests thus less latency and cost; Image processing to cache filters or resizing or in data analytics to cache metrics or aggregate. Attached is a memoization example #JavaScript #FunctionalProgramming #CleanCode #SoftwareEngineering #SoftwareDevelopment #SoftwareTips #letsconnect #buildinpublic
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