🚀 Day 10 of #100DaysOfCode Today’s problem: Two Sum 🔢 🔍 What I learned: Brute force approach using nested loops Understanding time complexity (O(n²)) Importance of optimizing using HashMap (next step 🚀) 💡 Approach: Checked every pair of elements If their sum equals the target → return indices 📊 Result: ✅ All test cases passed (63/63) ⏱️ Runtime: 1780 ms 🧠 Learned that brute force works, but it's not efficient 🔥 Key takeaway: There’s always a better way! Next step → solve this using HashMap in O(n) Consistency is building momentum 💯 #LeetCode #DSA #CodingJourney #Day10 #Python #ProblemSolving
Optimizing Two Sum Problem with HashMap in Python
More Relevant Posts
-
🚀 Day 9 of #100DaysOfCode Today’s problem: Valid Anagram ✅ 🔍 What I learned: How to check if two strings are anagrams Importance of sorting vs frequency counting Strengthened my understanding of strings & hashing concepts 💡 Approach: I used a simple and clean method: Sort both strings Compare them If equal → Anagram ✔️ 📊 Result: ✅ All test cases passed (54/54) ⏱️ Runtime: 19 ms 🔥 Key takeaway: Sometimes a simple solution is enough, but there’s always room to optimize using hash maps for better performance. Consistency > Perfection 💯 Let’s keep going! #LeetCode #DSA #CodingJourney #Day9 #Python #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 62 of #100DaysOfCode Solved “Remove Nth Node From End of List” 🔗 💡 Today’s focus: Two Pointer Technique (Fast & Slow pointers) Instead of calculating length, I used an efficient one-pass approach to remove the target node. 🧠 Key Learnings: Dummy node helps handle edge cases (like removing head) Fast pointer moves n steps ahead Then move both pointers until fast reaches the end Slow pointer lands just before the node to delete ⚡ Clean, efficient & optimal solution (O(n) time, O(1) space) Consistency is starting to feel powerful now 💪 #DSA #LeetCode #CodingJourney #LinkedInLearning #100DaysOfCode #Day62 #Python #ProblemSolving
To view or add a comment, sign in
-
-
Day 109 Backtracking patterns are repeating again — and that’s a good sign. #Day109 🧩 78. Subsets How today went: • Used recursion to explore all elements • At each step, decide to include or skip the current element • Append current subset → explore → then pop to backtrack • Move to the next index and repeat What I’m noticing: Subsets is one of the cleanest backtracking patterns: → choose → explore → undo Another revision day, but clarity is improving. Consistency continues. #LeetCode #DSA #Python #Backtracking #Recursion #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
Day 81 Heap patterns are starting to feel intuitive now. #Day81 🧩 973. K Closest Points to Origin Key idea: • Use a min heap • Calculate distance using squared values (no sqrt needed) • Push points into heap based on distance • Pop k closest elements What I liked about this problem: A small optimization (avoiding sqrt) makes it simpler and faster. These small tricks make a big difference. Consistency is turning patterns into instincts. #LeetCode #DSA #Python #Heap #PriorityQueue #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
DSA Tip: Binary Trees (Part 2) Building a tree is one thing… traversing it is where the real power comes in. In Binary Trees, we don’t just store data, we visit nodes in a specific order. The 3 main ways: Inorder (Left -> Root -> Right) Preorder (Root -> Left -> Right) Postorder (Left -> Right -> Root) Each traversal gives a different perspective of the same data. Insight: How you traverse data can be just as important as how you store it. Quick Challenge: Given this tree: 5 / \ 3 7 What is the Inorder traversal? Drop your answer, I’ll review the best ones. FOLLOW FOR MORE DSA TIPS & INSIGHTS #DSA #BinaryTree #Python #CodingTips #LearnToCode
To view or add a comment, sign in
-
-
🐍 Week 17 – Refining My Python Skills 🐍 This was a shorter week due to some personal commitments, but I focused on implementing the quicksort algorithm. Like last week with merge sort, I wanted to deeply understand how quicksort works. Here are the key concepts I worked on: - Implemented a separate partition function to split around a pivot. In my approach, I used three buckets (left, middle, right) to handle duplicates more cleanly and avoid unnecessary comparisons. - Created a quick_sort function to implement the main algorithm, recursively sorting the partitions until the base case was met. After practicing merge sort, quicksort felt more intuitive, and the concepts connected more easily. In Week 18, I plan to practice implementing the Luhn Algorithm. #Python #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
Day 106 Some problems feel simple when the pattern clicks. #Day106 🧩 17. Letter Combinations of a Phone Number How today went: • Used a digit → letters map • Built combinations using backtracking • Maintained a string path at each step • One recursive call per choice — no need for complex state handling What I realized: Once you understand the pattern: → choose a letter → move to next digit → build the path Backtracking becomes very natural. Simple problem, but great for building confidence. #LeetCode #DSA #Python #Backtracking #Recursion #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
Day 51 of #GeekStreak60 🚀 Today’s problem was about finding an increasing subsequence of size 3 📈 🧠 Core Idea For every element, check if there’s a smaller element before it and a greater element after it. 💡 What I Did → Precomputed: • smaller[] → index of smaller element on the left • greater[] → index of greater element on the right → Scanned the array to find a valid triplet efficiently 📚 What I Learned This problem showed how preprocessing arrays can simplify sequence problems and help achieve linear time complexity ⚡ ✅ Day 51 complete Beyond 50 and still going strong 💪🔥 #GeekStreak60 #GeeksforGeeks #NPCI #Day51 #ProblemSolving #Python #CodingJourney
To view or add a comment, sign in
-
-
Day 105 Backtracking is becoming more structured now. #Day105 🧩 131. Palindrome Partitioning How today went: • Iterated through the string, taking one substring at a time • Used DFS to explore partitions • Checked if each substring is a palindrome before going deeper • Built the result step by step and backtracked when needed What clicked: At each step: → choose a substring → validate (palindrome) → explore further → backtrack This pattern is repeating across problems. Backtracking is slowly becoming more intuitive. #LeetCode #DSA #Python #Backtracking #DFS #Recursion #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
Day 5/100 — Mastering the Basics that Matter Today I solved: Remove Duplicates from Sorted Array At first glance, it looks simple… but the real challenge was: Solving it in-place Maintaining O(1) space complexity Applying the Two Pointer technique efficiently Approach: Used two pointers (i & j) where: i tracks the last unique element j scans the array Whenever a new element is found, we update in-place — no extra space needed. Key Takeaways: Writing optimal code > just solving the problem In-place operations are super important for interviews Two pointers = must-know pattern in DSA Small problems like these build strong foundations for bigger challenges. Consistency continues… #100DaysOfCode #Day5 #DSA #LeetCode #Python #CodingJourney #ProblemSolving #TechGrowth #SoftwareEngineering #Consistency #KeepGrinding
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