Day 15 of #100DaysOfLeetCode Problem: 200. Number of Islands Category: Graph / DFS / Matrix Traversal Today’s challenge was about counting the number of islands in a 2D grid, where each island is represented by connected land cells. This problem is a perfect example of applying Depth-First Search (DFS) to explore connected components in a matrix. 🧠 Key Learnings: Implemented DFS recursively to explore all connected land cells ('1'). Used boundary checks to avoid out-of-range access and prevent redundant traversals. Learned how grid traversal and state marking (changing visited land to '0') help track visited nodes. Strengthened understanding of how recursive search algorithms work in multidimensional data structures. 🎯 Takeaway: Recursive thinking and systematic traversal are powerful tools — understanding them deeply opens the door to solving many graph and matrix problems efficiently. #LeetCode #100DaysOfCode #ProblemSolving #CodingJourney #Graphs #DFS #Recursion #Python #AIEngineer #Consistency
Solved 200. Number of Islands with DFS on LeetCode
More Relevant Posts
-
✅ Day 96 Completed – Inorder Traversal Today’s challenge was all about performing Inorder Traversal on a binary tree — a fundamental operation in tree data structures. 🧩 Concept: Inorder traversal visits nodes in the Left → Root → Right order. The task was to implement it without using recursion or an explicit stack, making it an interesting optimization problem. 💡 Approach: The solution uses the Morris Traversal algorithm, which cleverly utilizes threaded binary trees to achieve traversal in O(1) space complexity. It creates temporary links (threads) to predecessor nodes. Once a node’s left subtree is visited, the link is removed, ensuring no extra memory usage. ⚙️ Key Highlights: Space-efficient (no recursion/stack) Time complexity: O(N) All test cases passed ✅ (1111/1111 with 100% accuracy) 🌱 Takeaway: This problem deepened my understanding of space-optimized tree traversal techniques and their practical applications. #100DaysOfCode #Day96 #GeeksforGeeks #Python #DataStructures #BinaryTree #InorderTraversal
To view or add a comment, sign in
-
-
Day 14 of #100DaysOfLeetCode Problem: 136. Single Number Category: Arrays / Bit Manipulation / Hashing Today’s problem was about finding the element that appears only once in an array where every other element appears twice. It’s a great problem to strengthen both logical thinking and pattern recognition in data structures. 🧠 Key Learnings: Used frequency counting to identify the unique element among duplicates. Reinforced the idea that there’s always more than one way to solve a problem — from counting occurrences to using bitwise XOR. Improved understanding of how space and time trade-offs play a big role in algorithm design. Built confidence in working with array traversal and element comparisons. 🎯 Takeaway: Even simple problems can reveal deep insights into efficiency — sometimes the cleanest logic leads to the most optimal solution. #LeetCode #100DaysOfCode #ProblemSolving #CodingJourney #Arrays #Python #AIEngineer #Consistency
To view or add a comment, sign in
-
-
🚀 𝐃𝐚𝐲 𝟏𝟑 𝐨𝐟 #𝟏𝟔𝟎𝐃𝐚𝐲𝐬𝐎𝐟𝐂𝐨𝐝𝐞 — 𝐏𝐚𝐥𝐢𝐧𝐝𝐫𝐨𝐦𝐞 𝐍𝐮𝐦𝐛𝐞𝐫 | 𝐒𝐭𝐫𝐢𝐧𝐠𝐬 🧩 Today’s focus was on a simple yet classic logic check — determining if a number reads the same forward and backward. While it looks straightforward, it’s a great reminder that elegant solutions often come from clarity, not complexity. Problem: 𝐂𝐡𝐞𝐜𝐤 𝐢𝐟 𝐚𝐧 𝐢𝐧𝐭𝐞𝐠𝐞𝐫 𝐢𝐬 𝐚 𝐩𝐚𝐥𝐢𝐧𝐝𝐫𝐨𝐦𝐞. Approach: Convert the integer to a string and compare it with its reverse. Time Complexity: O(n) Space Complexity: O(n) This small exercise reinforces foundational reasoning that scales up when designing more complex systems — where reversing, mirroring, or symmetry detection shows up in data validation, pattern recognition, and even natural language tasks. 🔗 GitHub: https://lnkd.in/gaim_PJS #Python #LeetCode #CodingChallenge #160DaysOfCode #ProblemSolving #DSA #AIEngineerJourney
To view or add a comment, sign in
-
🧩 Day 30 — 4Sum (LeetCode 18) 📝 Problem -Given an integer array nums, return all unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: -a, b, c, and d are distinct indices -nums[a] + nums[b] + nums[c] + nums[d] == target -Return the answer in any order. 🔁 Approach -Sort the array to handle duplicates efficiently. -Use a recursive k-sum approach that generalizes 2-sum, 3-sum, and 4-sum problems. -For k > 2, recursively reduce the problem: -Fix one number and call kSum for k - 1 on the remaining array. -Skip duplicates to avoid repeating quadruplets. -For k = 2, use the two-pointer technique: -Move pointers inward based on the sum comparison with the target. -Add valid pairs to the result and skip duplicates. -Backtrack after each recursive call to explore all possible combinations. 📊 Complexity -Time Complexity : O(n³) -Space Complexity : O(k) 🔑 Concepts Practiced -Recursive K-Sum pattern -Two-pointer technique -Sorting and duplicate handling -Backtracking with controlled search space #python #DSA #4Sum #ProblemSolving #Leetcode
To view or add a comment, sign in
-
-
This script compares two regression models applied to Panama’s population data (1950–2024): Linear Regression (red line): Tries to fit a straight line to the data. It assumes population increases at a constant rate over time. Polynomial Regression (green curve, degree 2): Fits a curved (quadratic) line that allows for acceleration in growth. This model captures non-linear changes — for example, faster growth in recent decades. #python #statistics #artificialinteligence
To view or add a comment, sign in
-
-
#LearnPythonWithMe Dijkstra’s Algorithm — A Deep Dive into Graph Theory & Pathfinding! I recently explored Dijkstra’s Algorithm in Python and ended up learning way more than I expected! 🌐💡 Here’s what I covered and understood in depth: Graph Representation: Learned how graphs can be represented as adjacency lists, where each node maps to its connected nodes and their edge weights. Weighted Graphs: Understood that each edge has a cost or weight, representing distance, time, or any measurable value. Shortest Path Algorithm: Dijkstra’s Algorithm helps find the minimum distance from a start node to all other nodes in a weighted graph. Priority Queue (Min-Heap): Implemented efficient node selection using Python’s heapq module — it always picks the next node with the smallest known distance. Relaxation Technique: Grasped how the algorithm updates distances dynamically when a shorter path is found. Time Complexity Analysis: Explored why Dijkstra’s runs efficiently with O((V + E) log V) using a heap-based priority queue. This project didn’t just help me understand how data structures and algorithms work together — it gave me hands-on insight into optimization logic, traversal mechanisms, and performance tuning in real-world systems. Can’t wait to dive deeper into other advanced graph techniques next! Guided by Dev Bhushansir #Python #Algorithms #DataStructures #GraphTheory #Dijkstra #CodingJourney #LearningInPublic #ProgrammerLife #TechLearner #BCA #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Handling Outliers in the USA Housing Dataset using IQR Method In this step, I focused on improving data quality by detecting and removing outliers from the dataset. Outliers can significantly affect model accuracy, so cleaning them is an essential part of preprocessing. 🧮 Steps Performed: 1. Selected numeric columns from the dataset using select_dtypes(). 2. Calculated Q1 (25th percentile) and Q3 (75th percentile) for each column to determine the Interquartile Range (IQR). 3. Defined upper (positive) and lower (negative) outlier limits as: Q3 + 1.5 × IQR and Q1 − 1.5 × IQR 4. Used these limits to filter out rows containing any values outside this range. 5. Combined the cleaned numeric data with the non-numeric columns to form the final dataset. ✅ Result: The new DataFrame USAHousing_filtered contains only valid, non-outlier data — ready for reliable analysis and model building. 📊 #DataCleaning #OutlierDetection #MachineLearning #DataPreprocessing #Python #DataScience #Pandas #JupyterNotebook #USAHousingDataset
To view or add a comment, sign in
-
-
🧩 Day 29 — 3Sum Closest (LeetCode 16) 📝 Problem Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. 🔁 Approach -Sort the array to use the two-pointer technique effectively. -Iterate through each element nums[i] (except the last two) and treat it as the first element of the triplet. -For each i, set two pointers: -left = i + 1 -right = len(nums) - 1 -Compute the sum of the three numbers: -total = nums[i] + nums[left] + nums[right] -If total == target, return total immediately (perfect match). -Otherwise, compare the absolute difference between total and target to update the closestSum. -Adjust pointers: -If total < target, move left pointer right to increase sum. -If total > target, move right pointer left to decrease sum. -Continue until all triplets are checked. -Return the final closestSum. 📊 Complexity -Time Complexity: O(n²) -Space Complexity: O(1) 🔑 Concepts Practiced -Sorting and two-pointer pattern -Optimization using sorted array and pointer movement -Handling duplicates efficiently -Absolute difference comparison for closest value #Leetcode #python #DSA #Sorting #problemSolving
To view or add a comment, sign in
-
-
Day 13 of #100DaysOfLeetCode Problem: 88. Merge Sorted Array Category: Arrays / Sorting / Two Pointers Today’s challenge focused on merging two sorted arrays into one, maintaining the sorted order. It’s a simple yet powerful problem that tests your understanding of array indices, merging logic, and in-place updates. 🧠 Key Learnings: Extended the first array by adding elements from the second, then sorted the combined list. Reinforced the importance of efficient merging techniques for sorted sequences. Understood how in-place operations can reduce memory usage in practical scenarios. Strengthened logic building around sorting fundamentals and index-based insertion. 🎯 Takeaway: Even simple array problems help build strong fundamentals in sorting and data manipulation — the key to mastering larger algorithmic challenges. #LeetCode #100DaysOfCode #ProblemSolving #CodingJourney #Arrays #Sorting #Python #AIEngineer #Consistency
To view or add a comment, sign in
-
-
🔹 Day 2 of 30 – LeetCode Challenge: Postorder Traversal of Binary Tree 🌲Today’s problem was about implementing Postorder Traversal of a binary tree — one of the most fundamental tree traversal techniques in Data Structures and Algorithms. 🧩 Problem: Return the postorder traversal (Left → Right → Root) of a given binary tree. Example: Input: root = [1, null, 2, 3] Output: [3, 2, 1] 💡 Approach: In Postorder Traversal, we: Visit Left Subtree Visit Right Subtree Visit Root Node I implemented both recursive and iterative approaches. The recursive version is simpler, while the iterative version helps understand how to simulate recursion using a stack. ⚙️ Complexity: Time Complexity: O(n) Space Complexity: O(h) 🏆 Result: ✅ All test cases passed 🚀 Runtime Efficiency: 100% 💬 Learning: This problem helped me deepen my understanding of recursion and stack-based traversal logic. Iterative postorder traversal is tricky but a great exercise to strengthen logical thinking in DSA. #LeetCode #Day2 #Python #DataStructures #BinaryTree #PostorderTraversal #Algorithms #Recursion #30DaysOfCode #MTech #CodingChallenge
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