Day 10: 90-Day Coding Challenge 🚀 Continuing the journey by strengthening my fundamentals in array-based problems and improving problem-solving efficiency. Today’s problem focused on the classic Two Sum problem. The goal was to find two indices in an array such that their values add up to a given target. At first, a brute-force approach using nested loops works, but it results in O(n²) time complexity, which is not efficient for larger inputs. Instead, I used an optimized approach with a HashMap (dictionary): • Iterated through the array once • Stored each number along with its index • Checked if the complement (target - current number) already exists • Returned the indices as soon as a match is found This approach reduces the time complexity to O(n) with O(n) space complexity. Today’s learning highlights: ✅ Understood the importance of optimizing brute-force solutions ✅ Learned how HashMaps improve lookup efficiency ✅ Strengthened problem-solving with single-pass solutions ✅ Improved thinking in terms of time vs space trade-offs Simple problems like these are great for building strong fundamentals and efficient thinking 💡 Excited to keep the momentum going! #90DaysOfCode #DataStructures #Algorithms #Python #CodingJourney #Arrays #HashMap
Optimizing Two Sum Problem with HashMap
More Relevant Posts
-
🚀 Day 55 | Sorting Algorithms Today, I explored the fundamentals of sorting algorithms as part of my journey with 10000 Coders. 🔹 Bubble Sort • Compares adjacent elements repeatedly • Swaps them if they are in the wrong order • After each pass, the largest element moves to the end 🔹 Selection Sort • Finds the minimum element from the unsorted portion • Places it at the correct position • Gradually reduces the unsorted part 💡 Key Learnings: • Step-by-step understanding of how sorting works • Difference between comparison-based techniques • Importance of nested loops in sorting logic • Basic understanding of time complexity (O(n²)) This session helped me strengthen my foundation in Data Structures & Algorithms (DSA). 🚀 Taking small steps every day to improve my problem-solving and coding skills 💪 #Day55 #Python #SortingAlgorithms #ProblemSolving #10000Coders #PythonJourney #FullStackJourney #LearningDaily
To view or add a comment, sign in
-
Day 47 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to find a peak element in an array. A peak element is an element that is greater than or equal to its neighbors. What the program does: • Takes an array as input • Finds any peak element in the array • Handles edge cases (first and last elements) • Returns the peak value How the logic works: • If the array is empty → return None • If it has only one element → return that element • Check the first element: – If it is greater than or equal to the next element → it's a peak • Check the last element: – If it is greater than or equal to the previous element → it's a peak • Traverse the array from index 1 to n-2: – If an element is greater than or equal to both neighbors → return it • If no peak is found (rare case), return None Example: Input: [1, 3, 20, 4, 1, 0] Output: 20 Another example: Input: [1, 2, 3, 4, 5] Output: 5 Another example: Input: [5, 4, 3, 2, 1] Output: 5 Why this approach works: – Checks boundary conditions properly – Works for increasing and decreasing arrays – Time Complexity: O(n) Key learnings from Day 47: – Handling edge cases in arrays – Comparing neighboring elements – Writing clean traversal logic – Strengthening problem-solving skills #100DaysOfCode #Day47 #Python #PythonProgramming #Arrays #Algorithms #ProblemSolving #CodingPractice #DataStructures #InterviewPrep #LearnByDoing #DeveloperGrowth #ProgrammingJourney #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
📌 You can turn static data into interactive stories by mastering Plotly, version control, and reproducible deployment in just three steps. These practices will accelerate your research timeline, boost publication impact, and streamline collaboration, delivering measurable gains across your scientific career. ✓ 🎓 Complete the free Plotly Python tutorial on plotly.com and create your first interactive scatter plot. ✓ 📁 Store Plotly scripts in a GitHub repository, document each graph in README, and update monthly. ✓ 🚀 Deploy an interactive Plotly Dash app via GitHub Pages, mint DOI on Zenodo, and mentor lab. 🟢 Which of these steps will you implement first in your own research workflow? #DataVisualization #Plotly #OpenScience #ResearchTools #CareerGrowth
To view or add a comment, sign in
-
-
📌 You can turn static data into interactive stories by mastering Plotly, version control, and reproducible deployment in just three steps. These practices will accelerate your research timeline, boost publication impact, and streamline collaboration, delivering measurable gains across your scientific career. ✓ 🎓 Complete the free Plotly Python tutorial on plotly.com and create your first interactive scatter plot. ✓ 📁 Store Plotly scripts in a GitHub repository, document each graph in README, and update monthly. ✓ 🚀 Deploy an interactive Plotly Dash app via GitHub Pages, mint DOI on Zenodo, and mentor lab. 🟢 Which of these steps will you implement first in your own research workflow? #DataVisualization #Plotly #OpenScience #ResearchTools #CareerGrowth
To view or add a comment, sign in
-
-
Some problems are not about removing elements, but about removing them wisely. Day 25/100 — Data Structures & Algorithms Journey Today’s Problem: Remove K Digits This problem helped me understand how greedy decisions can lead to an optimal solution. Approach: Instead of trying all possible combinations, I used a stack-based greedy approach. While traversing the number, I removed digits that were larger than the current digit to make the number as small as possible. If there were still digits left to remove, I removed them from the end. Finally, I handled leading zeros to get the correct result. At each step: - Remove larger digits from stack - Add current digit - Handle remaining removals - Remove leading zeros Key Takeaways: Greedy algorithms help make optimal local decisions Stack is useful for maintaining order Small changes can significantly impact the final result Thinking step-by-step avoids unnecessary complexity This problem strengthened my understanding of greedy strategies and stack usage. #DSA #LeetCode #Greedy #Stack #ProblemSolving #SoftwareEngineering #CodingJourney #100DaysOfCode #TechLearning #DeveloperJourney #Programming #Python #InterviewPreparation #CodingSkills #ComputerScience #FutureEngineer #TechCareers #SoftwareDeveloper #LearnInPublic #OpenToWork
To view or add a comment, sign in
-
-
🚀 Day 12/100: Scope & The Number Guessing Game! 🎯🔢 💡 Did you know? In the early days of computing, managing "Scope" was one of the biggest causes of system crashes. Today, understanding where your variables "live" is the secret to writing bug-free, professional code! I’ve hit Day 12 of #100DaysOfCode! Today was a deep dive into the internal mechanics of Python, specifically Global vs. Local Scope. Key technical takeaways: ✅ Scope Hierarchy: Understanding that variables created inside a function are local to that function. ✅ Global Constants: Learning the best practice of using UPPERCASE for global constants that don't change. ✅ Game Logic: Building a "Number Guessing Game" with Difficulty Levels (Easy vs. Hard). ✅ Namespace: Learning how Python tracks names to avoid variable conflicts. Mastering Scope is like mastering your internal energy—if you don't control where it flows, your whole program can fall apart! 🛡️ Check out my code here: 🔗 https://lnkd.in/gBZgiBxr The grind is getting intense. Day 13, show me what you've got! ⚔️ #Python #100DaysOfCode #ProgrammingLogic #VariableScope #CleanCode #CodingChallenge #DevCommunity
To view or add a comment, sign in
-
✅ Day 92 of 100 Days LeetCode Challenge Problem: 🔹 #2011 – Final Value of Variable After Performing Operations 🔗 https://lnkd.in/gX-JQNUJ Learning Journey: 🔹 Today’s problem was about evaluating a sequence of increment and decrement operations. 🔹 I initialized a variable ans = 0 to track the value. 🔹 Used a hashmap to map each operation to its effect: • "++X" and "X++" → +1 • "--X" and "X--" → -1 🔹 Iterated through the operations and updated ans accordingly. 🔹 Returned the final computed value. Concepts Used: 🔹 HashMap / Dictionary 🔹 String Matching 🔹 Simple Simulation Key Insight: 🔹 Instead of using multiple condition checks, mapping operations to values simplifies logic and improves readability. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
Episode 11: Mastering Python Functions — Write Less, Do More! 🚀🐍 Tired of copying and pasting the same blocks of code? In Episode 11 of our Python Zero to Pro series, we are unlocking the ultimate tool for clean, professional programming: Functions. While variables store data, Functions store actions. They are the building blocks of modular, scalable software. Whether you're building a simple calculator, automating a repetitive data cleaning task, or designing a complex neural network architecture, Functions allow you to write code once and reuse it infinitely. What’s inside today’s module: ✅ The Power of DRY (Don't Repeat Yourself): Learn why programmers hate repetition and how functions make your code cleaner and more efficient. ✅ Defining with def: Master the syntax for creating your own reusable blocks of code using the def keyword. ✅ Function Arguments: Go beyond static code! Learn how to pass information (names, numbers, data) into your functions to make them dynamic and flexible. ✅ Default Values: See how Python handles missing information by setting smart default arguments. ✅ The "Call" Logic: Understand how to trigger your functions at the exact moment you need them in your program. ✅ Real-World Efficiency: From personalized greeting systems to automated data processing, see how functions form the skeleton of every modern application. 🔗 Access the Ecosystem Here: 📂 GitHub (Code & Roadmaps): https://bit.ly/4utEK8m 🧪 Kaggle (Research Lab & Datasets): https://bit.ly/4sBjImu 🌐 Official Website: https://ailearner.tech 📺 Full Video Course (YouTube): https://bit.ly/4bmOW9J 📖 Exact Notebook Folder: https://bit.ly/3PAWNt5 How to Level Up with Us: Follow my profile for daily modules as we march toward AI mastery in 2026. Star the GitHub repo to keep your "AI Engineer Roadmap" updated and accessible. Comment "FUNCTION" below once you’ve completed today's exercises! I’ll be jumping in to check your progress and answer questions. Let’s keep building the future, one reusable block of code at a time. 💻🔥 #Python #AiLearner #AI2026 #MachineLearning #PythonSeries #DataScience #CodingLife #SoftwareEngineering #CleanCode
To view or add a comment, sign in
-
Day 43 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to find the Longest Common Prefix (LCP) among a list of strings. This is a popular problem that helps strengthen string manipulation and comparison logic. What the program does: • Takes a list of strings as input • Finds the common starting characters shared by all strings • Returns the longest common prefix • Handles edge cases like empty lists and single strings How the logic works: • If the list is empty, return an empty string • Sort the list of strings • Compare only the first and last strings (they will have the maximum difference) • Iterate character by character • Add matching characters to the prefix • Stop when characters don’t match • Return the final prefix Example: Input: ["flower", "flow", "flight"] Output: "fl" Another example: Input: ["dog", "racecar", "car"] Output: "" (No common prefix) Another example: Input: ["apple", "apricot", "april"] Output: "ap" Why this approach works well: – Sorting reduces comparisons to just two strings – Efficient and easy to implement – Time Complexity: O(n log n + m) Key learnings from Day 43: – String comparison techniques – Using sorting to simplify problems – Handling edge cases effectively – Writing optimized and clean logic #100DaysOfCode #Day43 #Python #PythonProgramming #Strings #Algorithms #ProblemSolving #CodingPractice #DataStructures #InterviewPrep #LearnByDoing #DeveloperGrowth #ProgrammingJourney #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
🚀 Day 20 of Consistency | #75DaysLeetCodeChallenge 🧠 Today’s Problem : Min Stack (#155) 💡 Key Learning: This problem teaches how to design a data structure that supports constant time minimum retrieval using an additional stack. ⚡ Approach: Use two stacks → one for values, one for minimums push → add value to main stack & min(current, previous min) to min stack pop → remove from both stacks top → return top of main stack getMin → return top of min stack 🧠 Why this works: Tracks minimum at every step Ensures all operations run in O(1) time Efficient use of auxiliary space 🔥 Result : ✔️ Runtime: 0 ms (Beats 100%) 📈 A classic design problem that strengthens understanding of stacks & optimization. A big thanks to Shivam Singh, Nikhil Yadav & Akshat Tiwari for this amazing challenge 🙌 Consistency is compounding. Keep going. 💪 #Day20 #LeetCode #DSA #CodingJourney #100DaysOfCode #Python #Stack #Consistency
To view or add a comment, sign in
-
Explore related topics
- Approaches to Array Problem Solving for Coding Interviews
- LeetCode Array Problem Solving Techniques
- Build Problem-Solving Skills With Daily Coding
- Python Learning Roadmap for Beginners
- Solving Sorted Array Coding Challenges
- How to Improve Array Iteration Performance in Code
- Tips for Mastering Algorithms
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