📅 Day 97 of #100DaysOfCode Problem: Is Graph Bipartite? (LeetCode 785) Approach (BFS + Graph Coloring): 1️⃣ Assigned colors to nodes while traversing the graph using BFS. 2️⃣ Started coloring an unvisited node with color 0. 3️⃣ Colored all adjacent nodes with the opposite color. 4️⃣ If two connected nodes had the same color → graph is not bipartite. 5️⃣ Repeated for all disconnected components. #100DaysOfCode #LeetCode #DSA #Graphs #BFS #GraphTheory #ProblemSolving #Cplusplus #CodingChallenge #Programming #DeveloperLife #DailyDSA #KeepLearning #TechCommunity #GrowthMindset #Motivation
Harsh Srivastava’s Post
More Relevant Posts
-
DAY->7 Solved "Sort Array By Parity II" on LeetCode using the Two Pointer Approach in C++. -> Runtime: 0 ms (Beats 100%) -> Optimized time complexity: O(n) -> Practicing efficient array manipulation and pointer techniques. Consistency in Data Structures & Algorithms is the key to improving problem-solving skills. #LeetCode #DSA #Programming #Cpp #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 47 of DSA Problem: Longest Palindromic Substring A palindrome reads the same forward and backward. The challenge was to find the longest such substring inside a given string. 💡 Key Idea: Expand around each character (center) and check both odd and even length palindromes. ⏱ Time Complexity: O(n²) 💾 Space Complexity: O(1) This problem reinforced how choosing the right approach can drastically reduce complexity compared to brute force solutions. Consistent practice is sharpening my problem-solving skills step by step. 💪 #DSA #Java #CodingPractice #LeetCode #Programming #ProblemSolving
To view or add a comment, sign in
-
-
Day 45/120: Equal partition - DP enters the picture One problem today. Felt different from recent backtracking problems. Partition Equal Subset Sum Can you partition an array into two subsets with equal sum? First insight: if the total sum is odd, impossible. You can't split an odd number evenly. Second insight: if sum is even, the problem becomes "can you find a subset with sum = total/2?" This is the classic subset sum problem. Solved it with DP. Create a boolean array where dp[i] represents whether sum i is achievable. For each number, update what sums become possible. Why this felt different: Backtracking would work - try including/excluding each element, check if you reach target. But DP is cleaner here. We're not finding all solutions or one specific solution - just checking if a solution exists. This is the first problem in a while where DP clearly beats backtracking. This problem reminded me that different techniques solve different problems best. Forty-five days in. The toolkit keeps expanding. #DSA #CodingJourney #100DaysOfCode #LeetCode #GeeksForGeeks #DynamicProgramming #SubsetSum #Algorithms #SoftwareEngineering #Programming #Learning #Day45
To view or add a comment, sign in
-
-
When you miss a base case🧠 What is the best way to check it, what do you guys think??💬 When working with recursion, the most important step is often the simplest one: 💻Define your base case first. Before thinking about the recursive calls, pause and ask, like what’s the worst or simplest condition where the function should stop? Most of the time, that’s your base case. A small reminder from experience: 👉 Start with the base case 👉 Think about edge conditions first 👉 Then build the recursive flow Strong foundations make complex problems manageable. You can also check out✨, and learn CPP from the basics💻: https://lnkd.in/gdPC4D6f #Recursion #Programming #CPP #DSA #problemSolving #leetcode #basecase #lpu
To view or add a comment, sign in
-
-
#Day58 Solved: Longest Substring Without Repeating Characters(Leetcode 3) Worked on one of the most asked string problems that really tests problem-solving and optimization skills. Problem: Find the length of the longest substring without repeating characters. Approach: Used the sliding window technique to efficiently track a valid substring. Instead of checking all possible substrings (which is slow), I dynamically adjusted the window: Expanded when characters were unique Shrunk when a duplicate appeared Key Learning: The biggest takeaway was understanding how to maintain a valid window rather than restarting every time a duplicate is found. Complexity: Optimized the solution from O(n²) to O(n) using the right approach. This problem strengthened my understanding of: Sliding Window Two Pointer Technique Optimizing brute force solutions #leetcode #dsa #programming #coding #slidingwindow #problemSolving
To view or add a comment, sign in
-
-
#Day56 solved LeetCode 169 Majority Element Problem: Find the element that appears more than ⌊n/2⌋ times in an array. Approach: Instead of using extra space like HashMap, I learned a very efficient method called the Boyer-Moore Voting Algorithm. The idea is simple: 1.Keep a candidate and a count 2.Increase count if same element appears 3.Decrease count if different element appears 4.The final candidate will be the majority element Time Complexity: O(n) Space Complexity: O(1) This problem taught me how powerful optimized logic can be compared to brute force solutions. #DSA #LeetCode #Coding #ProblemSolving #100DaysOfCode #Programmer #LearningJourney
To view or add a comment, sign in
-
-
Learning and strengthening fundamentals in C++ for Data Structures and Algorithms. Wrote a simple program to find the maximum element in an array. This helped me reinforce: • Array traversal • Comparison logic • Thinking step-by-step through a problem Sometimes the simplest problems build the strongest foundations. #CPlusPlus #DSA #Programming #CodingJourney #LearningInPublic #SoftwareDevelopment #ProblemSolving
To view or add a comment, sign in
-
-
C++ Tutorial 11 🚀 ► https://lnkd.in/g2KnvWPw ► Learn how data type modifiers in C++ can efficiently utilize memory! Discover short, long, signed, and unsigned modifiers, their effects on size and range of primitive data types. Perfect for optimizing your C++ applications. Start mastering data types today! C++ Tutorials Playlist: ► https://lnkd.in/gzxi6sph #CPPProgramming #LearnCPP #CPP #Programming #CodingLife #Codiing
To view or add a comment, sign in
-
-
🔗 Delete Node in a Linked List – CodeQuest Free Lesson Strengthen your understanding of linked lists by solving a classic node deletion problem while reinforcing pointer handling and core data structure fundamentals. ⌨️ Try it out: https://lnkd.in/gZGUgCPs #codequest #tutorialsdojo #coding #programming #learntocode
To view or add a comment, sign in
-
-
🚀 Day 182 of #200DaysOfCoding 📌 Problem: Check if Binary String Has at Most One Segment of Ones (LeetCode 1784) Today’s challenge was about checking whether a binary string contains at most one continuous segment of '1's. 🧠 Problem Understanding We are given a binary string s that starts with 1 and contains only 0 and 1. We need to verify that all 1s appear in one contiguous block. ✔ Valid Examples 111000 110 1000 ❌ Invalid Example 1001 → Here, the segment of 1s breaks and appears again later. 💡 Key Idea If we ever encounter 0 followed by 1, it means a new segment of 1s has started, which violates the condition. ⏱ Complexity Time Complexity: O(n) Space Complexity: O(1) Consistent practice like this is helping me strengthen my problem-solving and data structure skills every day. #Day182 #200DaysOfCoding #LeetCode #DSA #Programming #CodingJourney #ProblemSolving
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