Day 18/100 | #100DaysOfDSA Today’s problem: Longest Common Prefix Many strings. One shared start. Approach: • Take first string as prefix • Compare with others • Shrink prefix until it matches • If it becomes empty → no common prefix Time complexity: O(n × m) Big takeaway: Sometimes the solution isn’t adding more — it’s trimming smartly. Less guesswork. More refinement. 💡✨ #100DaysOfCode #LeetCode #DSA #Algorithms #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #ComputerScience #Consistency #Programmers #TechGrowth
Yogesh ..’s Post
More Relevant Posts
-
Day 33/100 | #100DaysOfDSA 🌳💻 Today’s problem: Binary Tree Postorder Traversal Postorder follows a simple rule: Left → Right → Root Approach: • Use recursion • Traverse left subtree • Traverse right subtree • Add the root at the end This ensures children are processed before the parent. Time Complexity: O(n) Space Complexity: O(h) (recursion stack) Big takeaway: Tree traversals are just different visiting orders — mastering them builds strong tree intuition. Stacking tree patterns daily. 🚀 #100DaysOfCode #LeetCode #DSA #BinaryTree #Trees #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
Day 35/100 | #100DaysOfDSA 🌳💻 Today’s problem: Same Tree The goal is to determine whether two binary trees are identical — meaning they have the same structure and the same node values. Approach: • Use recursion to traverse both trees simultaneously • If both nodes are null → they match • If one node is null and the other isn’t → trees are different • If node values differ → trees are different • Recursively check the left and right subtrees Both trees must match at every node for them to be considered the same. Time Complexity: O(n) Space Complexity: O(h) (recursion stack) Big takeaway: When comparing two trees, traverse them in parallel and validate structure and values at each step. Simple logic, but a great exercise for strengthening recursive tree thinking. One more tree pattern learned. 🚀 #100DaysOfCode #LeetCode #DSA #BinaryTree #Trees #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
🚀 #60DaysOfLeetCode – Day 32 Today’s problem was about removing all adjacent duplicates in a string. 🔹 Approach Used: Stack To efficiently handle consecutive duplicates, I used a stack-based approach: Traverse the string character by character. If the stack is not empty and the top element matches the current character, pop it (this removes the duplicate pair). Otherwise, push the current character onto the stack. Finally, build the result string from the stack and reverse it to maintain the correct order. 🔹 Key Learning: Using a stack helps simulate the process of removing adjacent duplicates in a single pass, achieving O(n) time complexity and avoiding unnecessary reprocessing. This problem highlights how stacks are powerful for handling sequential patterns and cancellations, especially in string manipulation problems. On to Day 33! 💻🔥 #LeetCode #DSA #Java #CodingChallenge #ProblemSolving #LearningInPublic #60DaysOfCode
To view or add a comment, sign in
-
-
Day 32/100 | #100DaysOfDSA 🌳✨ Today’s problem: Symmetric Tree A tree is symmetric if the left subtree is the mirror of the right subtree. Approach: • Use two queues • Compare left and right nodes together • Check mirror conditions at every step If values mismatch → Not symmetric. Time Complexity: O(n) Space Complexity: O(n) Big takeaway: Symmetry in trees is just mirror comparison at every level. Understanding trees deeper every day. 🚀 #100DaysOfCode #LeetCode #DSA #BinaryTree #Trees #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 20/60 Completed – LeetCode Problem of the Day Challenge Today’s challenge: Check if Binary String Has at Most One Segment of Ones The problem asks us to determine whether a binary string contains at most one continuous segment of '1's. 🧠 Approach & Key Learnings: • Traversed the string once from left to right. • Once a segment of '1's starts, we track it. • If we encounter '0' after the first segment of '1's, we mark that a break occurred. • If another '1' appears after that zero, it means there is more than one segment of ones → return false. • Otherwise, the string contains only one contiguous segment of ones → return true. ⚙️ Key Concepts Practiced: • String traversal • Segment detection in binary strings • Boolean flag tracking • Writing clean linear-time logic Small problem, but a good exercise in carefully tracking patterns while scanning a string. 20 days down. Consistency is getting stronger every day. ⚡ 40 days to go — staying locked in. 🔥 #LeetCode #60DaysChallenge #ProblemOfTheDay #DSA #Java #CodingJourney #Consistency #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 5 – Longest Consecutive Sequence. Today's problem focused on finding the longest consecutive sequence in an unsorted array, which helps strengthen understanding of sorting, edge cases, and sequence tracking. Approach Step 1 – Sort the Array Step 2 – Traverse the Array While iterating: 1️⃣ If elements are equal → skip duplicates 2️⃣ If nums[i] == nums[i-1] + 1 → increase sequence count 3️⃣ Otherwise → reset the count. Step 3 – Track Maximum Length. Github Code :- https://lnkd.in/gF8DqckJ #LeetCode #DSA #StriverA2Z #CodingJourney #Java #Arrays #ProblemSolving #CodingPractice #SoftwareEngineering #TechInterviewPrep #100DaysOfCode #DeveloperJourney #ComputerScience
To view or add a comment, sign in
-
-
LeetCode Problem #1920 – Build Array from Permutation Today I solved an interesting array problem that helped me understand indexing and array traversal better. 📌 Problem: Given a 0-indexed array `nums`, build a new array `ans` such that: `ans[i] = nums[nums[i]]` 📌 Approach: * Create a new array `ans` with the same length as `nums` * Traverse the array using a `for` loop * For each index `i`, access the value `nums[i]` * Use that value as an index again to get `nums[nums[i]]` * Store the result in `ans[i]` 📌 Key Concepts Practiced: ✔ Array traversal ✔ Nested indexing ✔ Understanding how values can act as indexes 📌 Time Complexity: O(n) – since we traverse the array only once. 📌 Key Takeaway: Sometimes the value inside an array can also represent an index, and understanding this idea helps solve many array-based problems efficiently. 💡 Learning Note This problem improved my understanding of **index-based operations and array manipulation**, which are fundamental concepts for solving many coding interview questions. #LeetCode #CodingPractice #Java #DSA #Arrays #ProblemSolving
To view or add a comment, sign in
-
-
Day 18 – Same Tree 🚀 Continuing my DSA journey with Striver’s A2Z Sheet / LeetCode practice. Today’s problem focused on checking whether two binary trees are identical, which is a classic tree recursion problem. Approach We compare both trees node by node using recursion. At each step: 1️⃣ If both nodes are null → trees match 2️⃣ If one is null → not same 3️⃣ If values differ → not same 4️⃣ Recursively check left and right subtrees Time Complexity : O(N). Space Complexity : O(N) . Github Code :- https://lnkd.in/guF5Vq9m #LeetCode #DSA #StriverA2Z #CodingJourney #Java #BinaryTree #Recursion #ProblemSolving #CodingPractice #SoftwareEngineering #TechInterviewPrep #Day18 #DeveloperJourney
To view or add a comment, sign in
-
-
Day 33 of Practicing DSA on LeetCode Solved: • (21) Merge Two Sorted Lists – Easy Focused on: • Merging two sorted linked lists efficiently • Using a dummy node to simplify pointer handling • Comparing nodes and rewiring links in-place • Avoiding extra space while maintaining order This problem looks simple, but it builds the foundation for many advanced linked list patterns. Small problems → strong fundamentals. Consistency over everything. #DSA #Java #LeetCode #LinkedList #ProblemSolving #Consistency #LearningInPublic
To view or add a comment, sign in
-
-
Every problem teaches something new — today it was LeetCode 50: Pow(x, n) At first, it looked simple: just calculate power. But the real challenge was optimizing it and handling edge cases like negative powers and Integer.MIN_VALUE overflow. Learned how Binary Exponentiation can turn an O(n) solution into O(log n) — that’s the beauty of algorithms! Moments like these remind me that problem-solving is not just about writing code, but thinking deeper. #LeetCodeJourney #DSA #KeepLearning #Java #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