✅ Day 38 of 100 Days LeetCode Challenge Problem: 🔹 #323 – Number of Connected Components in an Undirected Graph 🔗 https://lnkd.in/gRVWsWgZ Learning Journey: 🔹 Today’s problem focused on counting connected components in an undirected graph. 🔹 I represented the graph using an adjacency list built from the edge list. 🔹 Using Depth-First Search (DFS), I explored all nodes reachable from a starting node. 🔹 Each new DFS traversal from an unvisited node indicates a new connected component. Concepts Used: 🔹 Depth-First Search (DFS) 🔹 Graph Representation (Adjacency List) 🔹 Connected Components 🔹 Graph Traversal Key Insight: 🔹 Graph problems often reduce to exploring connectivity between nodes. 🔹 Tracking visited nodes prevents redundant traversals. 🔹 Iterative DFS using a stack provides a clean and efficient solution. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
100 Days LeetCode Challenge: Number of Connected Components in an Undirected Graph
More Relevant Posts
-
✅ Day 39 of 100 Days LeetCode Challenge Problem: 🔹 #114 – Flatten Binary Tree to Linked List 🔗 https://lnkd.in/g6xn2K3g Learning Journey: 🔹 Today’s problem focused on transforming a binary tree into a flattened linked list in-place. 🔹 I used an iterative approach, modifying pointers while traversing the tree. 🔹 For each node with a left subtree, I found the rightmost node of that subtree and connected it to the current node’s right subtree. 🔹 Then, I moved the left subtree to the right and continued traversal. Concepts Used: 🔹 Binary Trees 🔹 Tree Traversal 🔹 Pointer Manipulation 🔹 In-place Modification Key Insight: 🔹 Tree restructuring problems often rely on careful pointer adjustments. 🔹 Finding the predecessor (rightmost node of left subtree) helps preserve traversal order. 🔹 Iterative solutions can avoid recursion and reduce extra space usage. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 61 of 100 Days LeetCode Challenge Problem: 🔹 #260 – Single Number III 🔗 https://lnkd.in/gKWtdDrb Learning Journey: 🔹 Today’s problem focused on finding the two elements that appear only once in an array where all others appear twice. 🔹 I used a frequency counting approach with Counter to track occurrences. 🔹 Then, I iterated through the dictionary and collected elements with frequency equal to 1. 🔹 This straightforward method ensures correctness with clear logic. Concepts Used: 🔹 Hash Map / Dictionary 🔹 Frequency Counting 🔹 Array Traversal 🔹 Filtering Logic Key Insight: 🔹 Hash-based counting simplifies duplicate detection problems. 🔹 When constraints allow extra space, clarity can be prioritized over bit-level optimization. 🔹 This problem also has an advanced XOR-based O(1) space solution, but counting keeps the implementation simple and readable. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 58 of 100 Days LeetCode Challenge Problem: 🔹 #1680 – Concatenation of Consecutive Binary Numbers 🔗 https://lnkd.in/gt22hnfF Learning Journey: 🔹 Today’s problem involved concatenating the binary representations of numbers from 1 to n. 🔹 I generated binary strings using bin(i)[2:] and appended them sequentially. 🔹 After forming the final binary string, I converted it back to an integer. 🔹 Since the result can be very large, I applied modulo 10**9+7. Concepts Used: 🔹 Binary Representation 🔹 String Manipulation 🔹 Modular Arithmetic 🔹 Simulation Key Insight: 🔹 Direct string concatenation works but is not optimal for large n. 🔹 Efficient solutions avoid large intermediate strings by using bit shifts and modular arithmetic at each step. 🔹 Understanding bit-length growth is crucial for optimization in binary construction problems. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 53 of 100 Days LeetCode Challenge Problem: 🔹 #191 – Number of 1 Bits 🔗 https://lnkd.in/gZPa-tQf Learning Journey: 🔹 Today’s problem focused on counting the number of set bits (1s) in the binary representation of an integer. 🔹 I converted the number to its binary form and iterated through the string representation. 🔹 By counting occurrences of '1', I determined the Hamming weight of the number. 🔹 This approach is simple and clear for understanding bit representation. Concepts Used: 🔹 Bit Manipulation 🔹 Binary Representation 🔹 String Conversion 🔹 Counting Technique Key Insight: 🔹 Every integer can be analyzed at the bit level for efficient computation. 🔹 Converting to binary provides an intuitive way to visualize set bits. 🔹 Bit manipulation problems often have multiple optimized approaches beyond basic counting. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 63 of 100 Days LeetCode Challenge Problem: 🔹 #1758 – Minimum Changes To Make Alternating Binary String 🔗 https://lnkd.in/gSY9BDhw Learning Journey: 🔹 Today’s problem focused on converting a binary string into an alternating pattern with minimum changes. 🔹 There are only two valid alternating patterns: starting with '0' (0101...) or starting with '1' (1010...). 🔹 I counted mismatches for both patterns while iterating through the string. 🔹 The answer is the minimum number of flips required between the two possibilities. Concepts Used: 🔹 String Traversal 🔹 Pattern Matching 🔹 Greedy Counting 🔹 Parity Indexing Key Insight: 🔹 When only two structural patterns are possible, evaluate both and choose the minimum cost. 🔹 Index parity (i % 2) is a clean way to enforce alternating constraints. 🔹 Comparing against expected patterns avoids unnecessary string reconstruction. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 57 of 100 Days LeetCode Challenge Problem: 🔹 #1404 – Number of Steps to Reduce a Number in Binary Representation to One 🔗 https://lnkd.in/ggb5GXaW Learning Journey: 🔹 Today’s problem focused on reducing a binary number to 1 using specific rules. 🔹 If the number is even, divide it by 2. If it is odd, add 1. 🔹 I converted the binary string to an integer, applied the operation, and converted it back to binary after each step. 🔹 The process continued until the value became "1", counting the total operations. Concepts Used: 🔹 Binary Representation 🔹 Bit Manipulation Concepts 🔹 Simulation 🔹 Conditional Logic Key Insight: 🔹 Binary problems often map directly to parity checks (even vs odd). 🔹 Simulation is straightforward but understanding bit behavior can lead to optimized solutions. 🔹 Recognizing patterns in binary transitions improves problem-solving efficiency. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 42 of 100 Days LeetCode Challenge Problem: 🔹 #204 – Count Primes 🔗 https://lnkd.in/gjsy54cm Learning Journey: 🔹 Today’s problem focused on counting the number of prime numbers less than a given integer. 🔹 I used the Sieve of Eratosthenes, an efficient algorithm for generating primes by iteratively marking multiples as non-prime. 🔹 Starting from 2, each prime eliminates its multiples, reducing unnecessary checks. 🔹 The remaining true values represent prime numbers. Concepts Used: 🔹 Sieve of Eratosthenes 🔹 Number Theory 🔹 Array Marking Technique 🔹 Optimization Key Insight: 🔹 Instead of checking each number individually, eliminating multiples significantly improves efficiency. 🔹 Starting from i² avoids redundant work because smaller multiples were already handled. 🔹 Preprocessing techniques like sieves are powerful for number-based problems. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 43 of 100 Days LeetCode Challenge Problem: 🔹 #684 – Redundant Connection 🔗 https://lnkd.in/gWtKJ-FA Learning Journey: 🔹 Today’s problem focused on detecting an extra edge that creates a cycle in an undirected graph. 🔹 I used the Union-Find (Disjoint Set Union) data structure to track connected components. 🔹 For each edge, I checked whether both nodes already belong to the same set. 🔹 If they do, adding that edge forms a cycle, making it the redundant connection. Concepts Used: 🔹 Union-Find (Disjoint Set) 🔹 Path Compression 🔹 Graph Cycle Detection 🔹 Connected Components Key Insight: 🔹 Union-Find provides an efficient way to detect cycles during edge additions. 🔹 Path compression optimizes repeated parent lookups. 🔹 Incrementally building connectivity helps quickly identify redundant edges. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 50 of 100 Days LeetCode Challenge Problem: 🔹 #696 – Count Binary Substrings 🔗 https://lnkd.in/gqvcumf3 Learning Journey: 🔹 Today’s problem focused on counting substrings where consecutive groups of 0s and 1s have equal length. 🔹 I analyzed transitions between groups of characters and counted valid balanced segments. 🔹 The idea was to track runs of consecutive characters and compare adjacent group lengths. 🔹 By accumulating the minimum of neighboring group sizes, I identified all valid binary substrings. Concepts Used: 🔹 String Traversal 🔹 Two-Pointer / Group Counting 🔹 Pattern Recognition 🔹 Greedy Counting Key Insight: 🔹 Binary substring problems often reduce to analyzing consecutive character groups. 🔹 Instead of checking all substrings, comparing adjacent group sizes gives an efficient solution. 🔹 Recognizing repeating patterns helps avoid brute-force complexity. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 40 of 100 Days LeetCode Challenge Problem: 🔹 #1200 – Minimum Absolute Difference 🔗 https://lnkd.in/gdXZxeGh Learning Journey: 🔹 Today’s problem focused on finding all pairs of elements with the minimum absolute difference in an array. 🔹 I first sorted the array so that the smallest differences would appear between adjacent elements. 🔹 By scanning the sorted list once, I tracked the minimum difference and collected all valid pairs. 🔹 This approach avoids unnecessary comparisons and improves efficiency. Concepts Used: 🔹 Sorting 🔹 Greedy Scanning 🔹 Array Traversal 🔹 Optimization Key Insight: 🔹 Sorting simplifies many comparison-based problems. 🔹 Minimum differences in a sorted array will always occur between neighboring elements. 🔹 Maintaining a running minimum helps build the result efficiently in one pass. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
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