🚀 Day 2 of #100DaysOfCode 📌 Reverse Integer 🔗 https://lnkd.in/gtKB8Mdi ✅ Accepted (All test cases passed) ⚡ Runtime: 0 ms 🧠 Approach: Reversed the number digit by digit using modulo and division, while handling overflow conditions carefully. ⏱️ Time: O(log n) | 📦 Space: O(1) 💡 Learning: Handling edge cases like overflow is the key part of this problem. #leetcode #dsa #cpp #coding #developers
Reverse Integer in C++ with O(log n) Time Complexity
More Relevant Posts
-
🚀 Day 81 of #100DaysOfCode 💡 Question 22: Generate Parentheses 🔍 Problem Statement: Given n pairs of parentheses, generate all combinations of well-formed parentheses. 🧠 Approach: - Use recursion with backtracking - Add an opening bracket if limit not reached - Add a closing bracket only if it keeps the sequence valid - Ensure balance at every step 📌 Key Takeaways: - Classic backtracking problem - Focus on constraints rather than brute force - Helps build strong recursion understanding 🔥 Solved successfully with optimized approach! #Day81 #100DaysOfCode #LeetCode #DSA #Backtracking #Coding #ProgrammingJourney
To view or add a comment, sign in
-
-
Day 56 of solving LeetCode. Today’s problem: Count Primes Result: Accepted ✔️ (66/66 test cases) Performance: • Runtime: 96 ms (beats 75.25%) • Memory: 51.26 MB Key takeaway: Brute force thinking doesn’t scale. The real shift is recognizing patterns like the Sieve of Eratosthenes — precompute smartly instead of checking repeatedly. Most people stay stuck trying to optimize loops. The smarter move is changing the approach entirely. Consistency > motivation. 56 days in. No breaks. No excuses. ∆ #LeetCode #CodingJourney #DSA #Programming #ProblemSolving #100DaysOfCode #DeveloperLife #CodingDaily #Algorithms #Consistency #GrowthMindset
To view or add a comment, sign in
-
-
Just solved a challenging binary tree problem! 🌳💻 🔍 Problem: Given a binary tree and an integer k, find the number of downward-only paths where the sum of node values equals k. ➡️ Paths can start and end at any node, but must always move from parent to child. 💡 Key Insight: Using prefix sum + hashmap during DFS traversal helps efficiently track all valid paths in O(n) time! ✅ All test cases passed ⚡ Optimized approach 🔥 Consistency streak continues! #geekstreak #gfg #npci #coding #dsa #binarytree #algorithms #100DaysOfCode #programming #developers #techgrowth
To view or add a comment, sign in
-
-
509: Resisting change in coding? Explore new tools like VS Code, Lovable, Base44, and Spark. Adapting is key. #Coding #DeveloperTools #TechTrends #SoftwareDevelopment
To view or add a comment, sign in
-
Day 6 🚀 Solved: Maximum Depth of Binary Tree (LeetCode 104) This is a classic recursion problem on trees. 💡 Key idea: The depth of a tree is 1 + the maximum depth of its left and right subtrees. 🔹 Approach: If the node is null → depth is 0 Recursively calculate depth of left and right Take the maximum and add 1 ⏱️ Time Complexity: O(n) 🔗 GitHub: https://lnkd.in/gz5mBpDx #DSA #LeetCode #Coding
To view or add a comment, sign in
-
Solved Add Two Numbers using linked lists. At first, the pointer-based structure was confusing, but breaking it down into simple steps made it manageable. Approach: Traverse both linked lists Add digits one by one Maintain carry (just like normal addition) Build a new linked list for the result #DSA #LinkedList #CPP #Coding
To view or add a comment, sign in
-
-
Day 63 – DSA Journey 🚀 | Detecting Cycles in Linked Lists Continuing my daily DSA practice, today I solved an important linked list problem on LeetCode using a two-pointer technique. 📌 Problem Practiced: Linked List Cycle (LeetCode 141) 🔍 Problem Idea: Given the head of a linked list, determine if the list contains a cycle. 💡 Key Insight: Using two pointers moving at different speeds helps detect a cycle efficiently without extra space. 📌 Approach Used: • Initialize two pointers: slow and fast • Move slow by 1 step and fast by 2 steps • If they meet → cycle exists • If fast reaches null → no cycle 📌 Concepts Strengthened: • Floyd’s Cycle Detection Algorithm • Two-pointer technique • Linked list traversal • Space optimization ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) 🔥 Today’s takeaway: Sometimes, moving at different speeds reveals hidden patterns—like cycles in linked lists. On to Day 64! 🚀 #Day63 #DSAJourney #LeetCode #LinkedList #TwoPointers #Java #ProblemSolving #Coding #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
🚀 Day 561 of #750DaysOfCode 🚀 📌 Problem: Minimum Distance to the Target Element Today’s problem was simple yet a great reminder of how powerful basic iteration can be when applied correctly. 🔍 The task was to find the minimum distance between a given start index and any index i such that nums[i] == target. 💡 Key Insight: Instead of overthinking, just iterate through the array and track the minimum value of |i - start| whenever the target is found. Clean, efficient, and effective. 🧠 What I Learned: Sometimes brute force with clarity is the best solution Always look for opportunities to minimize operations with simple logic Writing clean and readable code matters as much as solving the problem ⚡ Approach: Traverse the array Check for target Update minimum distance ⏱️ Complexity: Time: O(n) Space: O(1) 💻 Consistency is key. Small steps every day build strong problem-solving skills over time. #leetcode #dsa #programming #java #coding #developers #softwareengineering #100daysofcode #codingjourney #tech #learning #growth
To view or add a comment, sign in
-
-
Day 41 of 100 Days of Coding #100Daysofcoding #coding #dsa 1.Invert Binary Tree basic logic used - Just swap the left and right child , make sure to first swap the left then the right Pseudocode: If the current node is empty → return nothing Swap its left child and right child Go to the left side and repeat Go to the right side and repeat Return the current node At every node → swap → go left → go right Code : class Solution: def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: if not root: return None tmp=root.left root.left=root.right root.right=tmp self.invertTree(root.left) self.invertTree(root.right) return root Time Complexity- O(n) You visit every node exactly once Space Complexity- O(n) Recursive call stack = height of tree
To view or add a comment, sign in
-
-
SOLID PRINCIPLE PART - 8 WHAT IS LSP OR MEANING OF ‘L’? L — Liskov Substitution Principle 👇 👉 Child class should behave like parent ❌ Example: Bird → Fly() Ostrich → cannot fly ❌ 👉 Breaks system ✔ Fix: Separate flying behavior 👉 Correct inheritance = stable system 🔔 Follow me for more: TechClarityWithVijay 👤 Vijay Narayan Mishra https://lnkd.in/gaWaDqZj #dotnet #softwareengineering #backenddeveloper #cleanarchitecture #coding #developers #systemdesign #TechClarityWithVijay
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