Day 12 of #30DaysOfCode with Educative 🟦 Challenge: Middle of the Linked List (Easy) Approach: Slow–fast pointer technique Insight: Traverse the list with two pointers: the slow pointer moves one step at a time, and the fast pointer moves two steps. When the fast pointer reaches the end, the slow pointer naturally lands on the middle node; for even-length lists, this lands on the second middle, exactly as required. Tricky Part: The only small care point is the loop condition, checking both fast and next pointer to fast avoids null-pointer issues and cleanly handles both odd and even list lengths. #Educative #Python #SoftwareEngineering #ContinuousLearning #ProblemSolving
Linked List Middle Node Solution with Slow-Fast Pointer Technique
More Relevant Posts
-
Daily LeetCode Question | Day 1 ✅ LeetCode 1351: Count Negative Numbers in a Sorted Matrix ✔️ Used the two-pointer (staircase) approach starting from the top-right corner of the matrix. At each step, I leveraged the row-wise and column-wise sorted property to eliminate multiple elements at once instead of checking every cell. 🔹 Approach: Two Pointers (Staircase Search) 🔹 Time Complexity: O(m + n) 🔹 Space Complexity: O(1) This optimized approach avoids brute force and binary search, making it both efficient and interview-friendly. #LeetCode #DSA #TwoPointers #ProblemSolving #Python #CodingJourney
To view or add a comment, sign in
-
-
#Day3 of #100DaysofAI Day 3 was packed with Python control flow mastery and function building! Revised if/elif/else, for/while loops with break/continue, list comprehensions, then wrote 8 practical functions (add/subtract/multiply/divide, even/odd checker, prime tester, reverse number, Fibonacci generator). Built a Simple Calculator and Number Guessing Game as mini-projects. Key takeaway: print() shows output, return computes values — functions must return, never assign print() to variables. Control flow is logic's backbone! #AIJourney #LearningInPublic #Python #ArtificialIntelligence #BuildInPublic
To view or add a comment, sign in
-
Day 2: Diving Deeper into Python Building on yesterday’s basics, today I explored more core Python concepts: 🔹 Topics Covered: Control flow with if/elif/else Loops (for, while) and break / continue Functions: defining, calling, parameters, return values String operations & methods (split, join, replace, slicing) Lists & list methods (append, pop, sort) Tuples & Sets — understanding immutability and uniqueness Dictionaries — key-value pairs, .get(), .items() List & Dict Comprehensions for cleaner code 🔹 Mini Practice: Wrote a program to calculate factorial using both loops and functions Built a simple student grade dictionary and retrieved values dynamically #Python #Day2 #AIJourney #BuildInPublic #Generative
To view or add a comment, sign in
-
#100DaysLearningChallenge with Saurabh Shukla Sir 🎯 Day 70: Static vs Dynamic Linking Ever wondered why some programs run smoothly on any machine, while others need specific libraries to even start? That’s where static vs dynamic linking comes in. 🔹 C++ gives you a choice Static linking: all required code is bundled inside the executable Dynamic linking: libraries are linked at runtime 🔹 Python mostly follows dynamic linking Modules and shared libraries are loaded when the program runs Same destination, different paths. One focuses on control, the other on flexibility. #Day70 #StaticLinking #DynamicLinking #CPP #Python #100DaysLearningChallenge
To view or add a comment, sign in
-
Theory is good. Proof is better. 🐢 vs ⚡ We’ve all studied Multithreading in Python. We know the definitions. But have we actually performed the benchmark? I decided to put the theory to the test. wrote two scripts to download high-res images: 1️⃣ Single-Threaded: The standard loop we all write. 2️⃣ Multi-Threaded: Using ThreadPoolExecutor. That is a 60% performance increase just by changing how we handle I/O waiting time. Check out the video to see the race, and grab the code on my GitHub to try it yourself! 👇 https://lnkd.in/gZASrAUj #Python #RealWorldCoding #DataAnalysis #Multithreading #Performance
To view or add a comment, sign in
-
🎮✋🏻Built a gesture-controlled game🔥 using Python and OpenCV. This project transforms a webcam into a game controller by mapping real-time hand gestures to movement actions such as left, right, jump, and duck—eliminating the need for a keyboard. 🔑Key features include: - Compatibility with Python 3.13 - Smooth gesture filtering using Exponential Moving Average (EMA) and frame voting - A computer vision-based control system 👉🏻For more details, visit the GitHub repository: https://lnkd.in/gUd5zP3u #Python #OpenCV #ComputerVision #AIProjects #GitHub #LearningByDoing
To view or add a comment, sign in
-
LeetCode 191: Number of 1 Bits (also known as finding the Hamming Weight). The Efficiency Secret: While you can solve this using a while loop with bit-shifting or a string conversion, Python’s built-in bit_count() method is implemented directly at the C-level in the interpreter. It provides the most efficient way to count set bits in an integer. The Results: 🎯 Runtime: 0 ms (Beats 100.00%) 🧠 Memory: 17.53 MB (Beats 92.87%) This solve marks a great addition to my recent streak of 100% efficiency beats in both memory and runtime across various string and math problems. Consistency is paying off! #LeetCode #Python #BitManipulation #CleanCode #Optimization #SoftwareEngineering #Consistency
To view or add a comment, sign in
-
-
Today I solved the Longest Common Prefix problem, which focuses on string comparison and edge-case handling. 🔹 Problem: Given an array of strings, find the longest prefix common to all strings. If no common prefix exists, return an empty string. 🔹 Approach: ✔️ Take the first string as a reference ✔️ Compare characters index-by-index with all other strings ✔️ Stop immediately when a mismatch occurs #DSA #Python #ProblemSolving #CodingPractice #LeetCode #LearningJourney #SoftwareEngineering #Consistency
To view or add a comment, sign in
-
-
🚀 Day 12 of #100DaysOfCode – Understanding Scope in Python! Today I continued Angela Yu’s 100 Days of Python course and learned about local and global scope, an important concept for understanding how variables behave inside and outside functions. 🔹 What I learned today: Difference between local and global variables How scope affects variable access and modification 🔹 Simple Example: score = 10 # Global scope def update_score(): score = 5 # Local scope print(score) update_score() print(score) 💡 Project of the Day: Number Guessing Game I built a Number Guessing Game where the player tries to guess a randomly generated number within a limited number of attempts. This project was a great way to apply scope, functions, loops, and conditional logic together. Learning something new every day—on to Day 13! 🚀 #Python #100DaysOfCode #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
🚀 Day 14/50 — DSA Problem-Solving Challenge 🔍 Problem: Check Valid Anagram 🔹 Platform: HackerRank 🔹 Difficulty: Easy 💡 Problem Statement Given two strings, determine whether they are anagrams of each other. Two strings are anagrams if they contain the same characters with the same frequency, regardless of order. 🧠 Key Takeaways ✔ Understand how character frequency helps detect anagrams ✔ Sorting is an easy approach, but counting characters is more efficient ✔ Handles multiple cases like different lengths, repeated characters, etc. 🔧 Logic Used If lengths differ → Not an anagram Count occurrences of each character in both strings Compare both frequency maps If all counts match → Valid anagram #DSA #Day14 #CodingChallenge #ProblemSolving #Python #50DaysChallenge #LearningEveryday #Anagram
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