📅 Day 93 of #100DaysOfCode Problem: Palindrome Partitioning (LeetCode 131) Approach (Backtracking + Recursion): 1️⃣ Used backtracking to explore all possible substring partitions. 2️⃣ At each step, checked if the current substring is a palindrome. 3️⃣ If it is a palindrome → added it to the current path. 4️⃣ Recursively continued for the remaining substring. 5️⃣ Once we reached the end of the string → stored the valid partition. 6️⃣ Backtracked to explore other possible partitions. #100DaysOfCode #LeetCode #DSA #Backtracking #Recursion #Strings #ProblemSolving #Cplusplus #CodingChallenge #Programming #DeveloperLife #DailyDSA #KeepLearning #TechCommunity #GrowthMindset #Motivation
Palindrome Partitioning LeetCode 131 Solution
More Relevant Posts
-
📅 Day 95 of #100DaysOfCode Problem: Path Sum (LeetCode 112) Approach (Recursion / DFS): 1️⃣ Traversed the binary tree using Depth First Search (DFS). 2️⃣ Subtracted the current node value from the target sum. 3️⃣ When reaching a leaf node, checked if remaining sum equals node value. 4️⃣ Recursively checked both left and right subtrees. 5️⃣ Returned true if any root-to-leaf path matched the target sum. #100DaysOfCode #LeetCode #DSA #BinaryTree #DFS #Recursion #ProblemSolving #Cplusplus #CodingChallenge #Programming #DeveloperLife #DailyDSA #KeepLearning #TechCommunity #GrowthMindset #Motivation
To view or add a comment, sign in
-
-
📅 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
To view or add a comment, sign in
-
-
Leetcode potd : Sum of Root to leaf Binary Numbers Intuition : Since each node contains only 0 and 1, every root-to-leaf path naturally forms a binary number (with root as MSB). So idea is simple🌿, traverse all possible paths from root to leaf and keep building the number along the way instead of storing the full path. At every step, update the curr val so it represents the binary formed till that node. If reached the leaf node 🍃, that means one complete binary number is formed, so add to ans. So basically, it’s just dfs + building the number while moving down the tree. #leetcode #potd #problem_solving #consistency #consistency #programming
To view or add a comment, sign in
-
-
Leetcode POTD : Find Unique Binary Strings... Given an array that contains n unique binary strings, each of length n, and some possible strings are missing. Target: find a binary string of length n that is not present in the array. Thought process... Initially I thought of generating all possible binary strings of length n. Since the constraint was small, it passed all the test cases. But then I felt generating all 2^n strings just to find one missing is not really optimal, so I started thinking about a better approach 🤔 If we observe the examples carefully, we notice something interesting. There are n strings and each string has length n. Ohh yes, here is the trick 👀 Since the ansmust also be a string of length n, we can construct a new one ourselves. All the given strings are already unique, so if we flip the bit at index i from the i-th string (0 -> 1 or 1 -> 0), the newly formed string will differ from every string at least at one position. That guarantees the string will be unique and missing from the array ✨ Using this idea, the missing binary string can be found in O(n) time. #leetcode #potd #binary #strings #programming #problem_solving #consistency
To view or add a comment, sign in
-
-
DAY->12 Solved Running Sum of 1d Array on LeetCode today. Implemented the solution using the Prefix Sum technique to compute the cumulative sum of elements efficiently. -> Time Complexity: O(n) -> Space Complexity: O(n) All 54/54 test cases passed with 0 ms runtime. Small problems like this help strengthen fundamentals in arrays and prefix sums, which are widely used in many algorithmic problems. #LeetCode #DSA #CodingJourney #Programming #Cplusplus #ProblemSolving
To view or add a comment, sign in
-
-
🔥 Selection Sort – Code Implementation 🔥 Today I implemented Selection Sort 🧠💻 ✔️ Simple comparison-based sorting algorithm ✔️ Repeatedly selects the minimum element ✔️ Swaps it with the current index ✔️ Time Complexity: O(n²) Clean logic. Easy to understand. Great for learning sorting fundamentals. 🚀 #SelectionSort #DSA #CodingJourney #Programming #LearnToCode
To view or add a comment, sign in
-
I wrote a beginner-friendly article explaining 10 Pattern Problems in C++ with diagrams and code. Pattern problems are a great way to improve logic and understanding of loops. Check it out here: https://lnkd.in/grVA7Ggb #Programming #CPP #Coding
To view or add a comment, sign in
-
-
🚀 Binary Tree Root-to-Leaf Sum in C++ Just implemented a C++ solution to calculate the sum of all root-to-leaf binary numbers in a binary tree. How it works: DFS Traversal: Traverse the tree using Depth-First Search while building the path as a binary string. Binary Conversion: At each leaf, convert the accumulated binary string to its decimal equivalent. Sum Calculation: Keep adding each leaf’s decimal value to get the total sum. 💡 Key Concepts: 1.Tree traversal (DFS) 2.String manipulation 3.Binary-to-decimal conversion This approach is elegant for understanding tree paths and bitwise calculations without directly using bit manipulation! #CPlusPlus #BinaryTree #Algorithms #DSA #Coding #TreeTraversal #Programming
To view or add a comment, sign in
-
-
Duplicate enum values can hijack your reverse lookup. Two members are assigned the same numeric constant. A console.log reads the enum by that number. In production this can surface as wrong status codes. Logs may point to an unexpected enum name. Buggy conditionals silently pick the last defined key. Comment A, B, C, or D with the output you think appears and defend your choice. #typescript #programming #codinginterview #backend
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
-
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