🚀 Learning by Patterns — Contains Duplicate (LeetCode) https://lnkd.in/gfQmp-kU Another fundamental problem I practiced today: 👉 Contains Duplicate Simple on the surface, but it reinforces an important concept in problem solving. 🧠 Problem Understanding Given an array, return: 👉 True if any value appears at least twice 👉 False if all elements are unique 💡 Approaches I Practiced 1️⃣ Brute Force • Compare every pair • Works but very slow ⏱ O(n²) 2️⃣ Sorting Approach • Sort the array • Compare adjacent elements ⏱ O(n log n) 3️⃣ Using Set (Optimal) ⭐ • Use Python’s set() to track seen elements • If element already exists → duplicate found ⏱ O(n) 🧠 O(n) 🔥 Key Learning • Sets are powerful for checking duplicates • Hashing-based approaches simplify many problems • Always start simple → then optimize ⚡ My Realization Problems like this may look easy, but they build the foundation for more complex patterns. Understanding: • When to use set • When to sort • When brute force is acceptable is what really matters. Step by step, building clarity in fundamentals 🚀 #LeetCode #CodingPractice #ProblemSolving #DataStructures #LearningInPublic #BuildInPublic
Contains Duplicate Problem LeetCode Solution
More Relevant Posts
-
💡 A Simple Recursive Way to Check Power of Two Today I revisited a basic but interesting problem: Check if a number is a power of two. Instead of jumping straight to bit manipulation, I tried solving it using recursion — and it turned out to be a neat approach. 🔁 Idea: A number is a power of 2 if: It keeps dividing cleanly by 2 And eventually becomes 1 ⚙️ Approach: If n == 1 → ✅ True If n <= 0 or n is odd → ❌ False Otherwise → recursively check n // 2 ✨ What I liked about this: Very intuitive Mirrors the mathematical definition Easy to understand and implement 📊 Complexity: Time: O(log n) Space: O(log n) due to recursion stack 🧠 Takeaway: Sometimes, going back to the mathematical intuition behind a problem leads to the simplest solution. Of course, there’s also a more optimized bit manipulation trick: 👉 n & (n - 1) == 0 But recursion helps in building strong fundamentals. python code https://lnkd.in/giwyBUiQ How would you approach this — recursion or bit manipulation? 👇 #Algorithms #Recursion #Python #CodingInterview #ProblemSolving #LeetCode Rajan Arora
To view or add a comment, sign in
-
-
Everyone is telling non-technical people to learn to code. I think that's the wrong advice. The people moving fastest right now aren't the ones who learned Python. They're the ones who learned to think precisely. Vague input produces vague output. Every time. The bottleneck isn't code anymore. It's clarity. Learn to write precisely. Learn to describe outcomes instead of methods. Learn to give feedback specific enough to act on. That's the skill nobody is putting in the course catalog yet. Who have you seen thrive with AI tools — and what made the difference?
To view or add a comment, sign in
-
🚀 𝐏𝐲𝐭𝐡𝐨𝐧 𝐇𝐚𝐧𝐝𝐛𝐨𝐨𝐤 𝐓𝐡𝐚𝐭 𝐂𝐚𝐧 𝐓𝐚𝐤𝐞 𝐘𝐨𝐮 𝐅𝐫𝐨𝐦 𝐁𝐞𝐠𝐢𝐧𝐧𝐞𝐫 𝐭𝐨 𝐀𝐝𝐯𝐚𝐧𝐜𝐞𝐝 Most people learn Python randomly… But real growth comes from structured learning. This handbook covers everything you actually need ↓ 𝐅𝐨𝐮𝐧𝐝𝐚𝐭𝐢𝐨𝐧 (𝐏𝐚𝐠𝐞 𝟏–𝟒) → What is Python & why it’s powerful → Data types, operators, control flow → Loops and conditions 𝐂𝐨𝐫𝐞 𝐏𝐫𝐨𝐠𝐫𝐚𝐦𝐦𝐢𝐧𝐠 (𝐏𝐚𝐠𝐞 𝟓–𝟏𝟎) → Functions and arguments → Lists, Tuples, Dictionaries, Sets → File handling basics 𝐄𝐫𝐫𝐨𝐫 𝐇𝐚𝐧𝐝𝐥𝐢𝐧𝐠 (𝐏𝐚𝐠𝐞 𝟏𝟏) → try, except, finally → Handling real-world errors 𝐎𝐎𝐏𝐬 𝐂𝐨𝐧𝐜𝐞𝐩𝐭𝐬 (𝐏𝐚𝐠𝐞 𝟏𝟐) → Classes & Objects → Encapsulation, Inheritance, Polymorphism 𝐌𝐨𝐝𝐮𝐥𝐞𝐬 & 𝐑𝐞𝐠𝐄𝐱 (𝐏𝐚𝐠𝐞 𝟏𝟑–𝟏𝟒) → Organizing code into modules → Pattern matching using regex 𝐀𝐝𝐯𝐚𝐧𝐜𝐞𝐝 𝐓𝐨𝐩𝐢𝐜𝐬 (𝐏𝐚𝐠𝐞 𝟏𝟓–𝟐𝟎) → Decorators → Generators & Iterators → Context Managers → Lambda, Map, Filter → Async programming 𝐖𝐡𝐚𝐭 𝐦𝐚𝐤𝐞𝐬 𝐭𝐡𝐢𝐬 𝐩𝐨𝐰𝐞𝐫𝐟𝐮𝐥: Everything is explained in a simple, visual, step-by-step format Perfect for beginners and revision 𝐓𝐫𝐮𝐭𝐡: Learning Python syntax is easy Mastering concepts is what sets you apart 𝐓𝐢𝐩: Don’t just read Code every concept Build small projects Practice consistently That’s how you grow Save this if you're learning Python Follow me for more simple and practical tech content #Python #Programming #Coding #LearnPython #SoftwareDevelopment #TechCareers #Developers #Learning #CareerGrowth #AI
To view or add a comment, sign in
-
🚀 Don’t skip the basics. That’s where real strength is built. In the rush to learn GenAI, LLMs, and advanced ML concepts, it’s easy to overlook the foundations. But the truth is — strong fundamentals are what separate good developers from great ones. Today, I revisited a core Python concept: 👉 Lists vs Tuples Simple? Yes. Important? Absolutely. 🔹 Lists → Mutable, flexible, dynamic 🔹 Tuples → Immutable, faster, reliable Understanding when to use what is what really matters: ✔ Use Lists when data changes frequently ✔ Use Tuples for fixed, read-only data It’s not about memorizing syntax — it’s about thinking like a problem solver. 💡 Growth tip: Go back to basics regularly. Every time you revisit them, you’ll understand them at a deeper level. #Python #Programming #DataStructures #CodingBasics #SoftwareEngineering #LearnInPublic #AI #MachineLearning #GrowthMindset
To view or add a comment, sign in
-
-
🚀 You’ve probably used Python’s print() hundreds of times… But do you really know what it can do? 👀 Most developers only use it for basic debugging — but print() comes with 4 powerful parameters: 👉 sep — control how values are separated 👉 end — control how output ends 👉 file — redirect output anywhere 👉 flush — force real-time output These small features can actually: ✔ Improve your code readability ✔ Replace messy string formatting ✔ Help in logging & ML workflows I recently wrote a complete guide on Medium covering all of this with real examples and practical use cases 👇 🔗 https://lnkd.in/gtW_W8Ry A huge thank you to Javier Armando Jimenez Villafaña and Swapneel Solanki for supporting me throughout this article — for checking the content, verifying the code examples, and providing valuable feedback that helped shape the final version. Really appreciate it! 🙌 I am also on this learning journey myself — exploring Python, AI, and ML one topic at a time. If you found this useful, have questions, or just want to discuss Python, AI, or ML — drop a comment below or DM me directly. I would love to connect and learn together! #Python #Programming #MachineLearning #DataScience #SoftwareDevelopment
To view or add a comment, sign in
-
-
🧠 Building consistency, one concept at a time. 📅 Day 6 of my Python Journey Today was all about strengthening core fundamentals and taking a step closer to writing structured, efficient code. 💡 What I worked on today: 🔁 While Loops Practiced control flow using while loops. Solved multiple logic-building problems like: Reversing a number. Checking palindrome numbers. Digit-based operations. ⚙️ Functions Learned how to break problems into reusable blocks. Practiced writing clean and modular code. 🧩 Types of Arguments Explored different ways to pass values into functions. Understood flexibility in function design. 📦 Started Data Structures in Python – Lists After functions, I moved into in-built data structures, starting with Lists. From the practice files today, I covered: ✔️ Basics of list creation and manipulation ✔️ Hands-on with in-built methods like: append(), insert(), extend() remove(), pop(), del index(), count() sort(), reverse(), copy(), clear() Also explored how nested lists can be used to represent 2D structures like matrices. 🚀 What’s next? Moving forward, I’ll be solving problem-based questions on lists to strengthen my understanding and logic. 📌 Key Insight: It’s not just about learning syntax… It’s about understanding how and where to use it effectively. Consistency is building. Clarity is improving. And that’s what matters. #Python #Day6 #CodingJourney #DataStructures #LearningInPublic #ProblemSolving #Developers #TechGrowth #SDE #Programming
To view or add a comment, sign in
-
-
🚀 Day 3 – Building a Problem-Solving Mindset Still on the grind. Still showing up. Because consistency > motivation. 📌 Today’s Problem: Sum of N Natural Numbers Looks simple. But again… the goal is not just solving — it’s how efficiently you think. 🔹 Approaches Explored 1️⃣ Naive Approach → Basic step-by-step addition 2️⃣ Using Recursion → Function calling itself to solve smaller parts 3️⃣ Formula-Based Approach → Direct mathematical solution for maximum efficiency 💡 Key Takeaway Same problem. Three different approaches. Different levels of thinking. ✔️ Learned how multiple solutions exist for one problem ✔️ Understood that efficiency improves with better thinking 📈 Progress Update: From solving problems → to choosing the best approach Consistency is the real unlock 🔑 #Python #ProblemSolving #100DaysOfCode #Consistency #LearningJourney #DeveloperMindset
To view or add a comment, sign in
-
-
Workflow Experiment Tracking using skll #machinelearning #datascience #workflowexperimenttracking #skll Scikit learn laboratory This python package provides command line utilities to make it easier to run machine learning experiments with scikit learn. One of the primary goals of our project is to make it, so that you can run scikit learn experiments without actually needing to write any code other than what you used to generate/extract the feature. https://lnkd.in/g5fUxqd5
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