🔥 Day 172 of My LeetCode Journey Problem 129: Sum Root to Leaf Numbers 💡 Problem Insight: Today’s problem was about forming numbers from root-to-leaf paths in a binary tree and returning their total sum. Each path represents a number, so the challenge is building that number correctly while traversing. 🧠 Concept Highlight: The solution uses DFS with path accumulation: At each node, update the current value → current = current * 10 + node.val Traverse left and right When you reach a leaf, add the formed number to the total No need to store paths explicitly, just carry the value forward. 💪 Key Takeaway: Instead of storing full paths, carry forward the computed state. This keeps the solution clean, memory-efficient, and easy to reason about. ✨ Daily Reflection: This problem reinforced how tree traversal, combined with simple math, can solve seemingly complex problems. Understanding flow matters more than storing data. #Day172 #LeetCode #BinaryTree #DFS #PathSum #ProblemSolving #DSA #CodingJourney #Consistency
PRINCE KUMAR’s Post
More Relevant Posts
-
Day 21 of my Data Structures & Algorithms Journey 🚀 Solved: Flatten a Multilevel Doubly Linked List (LeetCode 430) 💡 Key Insight: Whenever a node has a child, treat it like a detour — go deep into the child list first, flatten it completely, and then reconnect back to the main list. 🧠 What I learned: • Depth First Search (DFS) approach in linked lists • Handling multiple pointers (next, prev, child) carefully • Importance of saving the next pointer before modifying links • How recursion helps simplify complex structures ⚡ Core Idea: Insert the child list in between the current node and its next node, then reconnect everything smoothly. 🔥 This problem really improved my understanding of pointer manipulation and recursive thinking! #LeetCode #DSA #LinkedList #Recursion #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 53 of solving LeetCode Today’s problem: Design Add and Search Words Data Structure 🔹 Focus: Trie + Backtracking 🔹 Key Learning: Handling wildcard searches (.) efficiently requires combining Trie traversal with DFS instead of brute force. This problem really tests how well you understand recursion and data structure design—not just implementation. 💡 Takeaway: If your approach still feels slow or messy, you're probably not leveraging the data structure properly. Clean design > brute force. ✅ Status: Accepted ⏱️ Runtime: 186 ms Consistency is still the only strategy. No shortcuts. #Day53 #LeetCode #DSA #CodingJourney #Consistency #ProblemSolving
To view or add a comment, sign in
-
-
#claudecode I am not a coder by any stretch of imagination — this was built using Claude Code for generation and NotebookLLM for troubleshooting in designated data set ( copied Hermes troubleshooting dataset into NotebookLM). Update: it is now built and tested: Dream state for local memory implementation. Yesterday I posted that the Consolidate + Prune loop was the missing piece. It is now running. The full memory loop is live: → Extract — every 6 hours, reads conversations, pulls new facts → Store — saves to local SQLite immediately → Consolidate — monthly, merges related facts into single cleaner statements → Prune — monthly, applies confidence decay and clears stale facts automatically First run pruned 6 stale facts and merged 2 into 1. Memory is already cleaner. Fully model agnostic — Gemma 4, Qwen, Llama, Mistral. Works with any local model via Ollama. Tested in a real environment. The screenshot is the implementation guide that gets sent on request. Three Python files, setup instructions, fully local LLM option included for teams that cannot use any external API. DM me ‘MEMORY’ for the full documentation. 👇 #AIAgents #FinanceAI #LocalLLM #BuildInPublic #DataPrivacy #IFRS
To view or add a comment, sign in
-
-
Day 26 of my Data Structures & Algorithms journey 🚀 Solved: Largest Number At Least Twice of Others (LeetCode 747) 💡 Key Takeaway: Instead of comparing the largest element with every other number, just track the largest and second largest. If max ≥ 2 × second max → condition satisfied ✔️ ⚡ What I improved: • Optimized thinking with single-pass solution (O(n)) • Avoided unnecessary comparisons • Strengthened fundamentals of array traversal #LeetCode #DSA #Arrays #CodingJourney #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 91/100 – LeetCode Challenge ✅ Problem: 148. Sort List 💡 Approach: Merge Sort on Linked List Today’s problem was a classic example of applying merge sort in a linked list to achieve: ✔ O(n log n) time complexity ✔ Efficient sorting without converting to array 🔍 Key Learnings: Used slow & fast pointer to split the list into halves Applied recursion to sort each half Merged two sorted linked lists efficiently Understood why merge sort is preferred for linked lists over quicksort ⚡ Result: Runtime: 9 ms (Beats 98.63%) Memory: 59.16 MB 💭 Insight: Linked lists don’t support random access, making merge sort the most optimal approach for sorting compared to other algorithms. Consistency > Motivation 💯 Almost nearing the finish line of this 100-day challenge! #Day91 #LeetCode #100DaysOfCode #DataStructures #Algorithms #LinkedList #MergeSort #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 42 of #LeetCode75 Problem: Reorder Routes to Make All Paths Lead to City 0 Today’s problem looked tricky at first, but the moment I understood the graph intuition, it became elegant 🔥 💡 Key Insight: We convert the directed graph into an undirected one while tracking edge directions. Original direction → needs change (cost = 1) Reverse direction → already correct (cost = 0) Then simply run DFS/BFS from node 0 and count how many edges need reversal. 🧠 What I Learned: How to handle direction in graphs using smart encoding Importance of transforming problems into simpler representations Strengthened my DFS concepts ⏱ Complexity: Time: O(n) Space: O(n) Problems like these remind me that clarity > complexity 📈 Consistency is the key — showing up every day! #Day45 #LeetCode #DSA #CodingJourney #SoftwareEngineer #GraphTheory #DFS #BFS #ProblemSolving #CodingDaily #TechJourney #LearningInPublic
To view or add a comment, sign in
-
-
Day 23 of my Data Structures & Algorithms Journey 🚀 Solved: Find Pivot Index (LeetCode 724) 💡 Key Insight: Instead of recalculating sums again and again, maintain a running left sum and use total sum to get the right sum instantly. 🧠 What I learned: • Prefix sum concept for optimization • Reducing time complexity from O(n²) → O(n) • Writing cleaner and more efficient logic ⚡ Core Idea: If leftSum == totalSum - leftSum - nums[i], then that index is the pivot. 🔥 Simple problem but a great reminder of how powerful prefix sums can be! #LeetCode #DSA #Arrays #PrefixSum #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🛣️ Built a Pothole Detection System with YOLO + FastAPI I recently worked on a full end-to-end computer vision project focused on detecting potholes in road images 🚀 What this project covers: • Data collection & annotation using Roboflow • Training multiple YOLO models • Model evaluation and comparison • Deployment with FastAPI • Real-time inference with annotated outputs 🧠 Model setup: I trained two versions for different trade-offs: ⚡ YOLO Nano → Faster inference → Lower accuracy 🎯 YOLO Small → Higher accuracy → Slightly slower This makes it flexible depending on whether speed or precision is more important. 🌐 Deployment: The models are served through a FastAPI backend with simple REST endpoints: • /predict_small → high accuracy • /predict_nano → fast inference You can upload an image and get: ✔ detected potholes ✔ bounding boxes on the image ⚙️ Tech stack: • YOLO (Ultralytics) • FastAPI • Roboflow • Python 📌 Repo: https://lnkd.in/d39kG_uz If you’re into computer vision or ML deployment, this is a solid practical project to try. Happy to discuss or collaborate.
To view or add a comment, sign in
-
Day 4 of #100DaysOfCode Solved: Rotate Function (LeetCode 396) Approach 1: Brute Force Rotate array each time → O(n) Recalculate F(k) → O(n) Total: O(n²) (Too slow) Approach 2: Optimized (Using Relation) Instead of recomputing, reuse the previous value: Each rotation shifts elements by +1 index Last element moves to index 0 Use relation to compute next value in O(1) Total: O(n) Key Intuition: When array rotates: Every element’s contribution increases by its value But we subtract n × last element to adjust Takeaway: Whenever a problem involves repeated recomputation after shifts/rotations look for a mathematical relation #LeetCode #DSA #CodingInterview #ProblemSolving #100DaysOfCode
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