Problem: Contains Duplicate (LeetCode #217) 💡 Concept Learned: Today I practiced a simple LeetCode problem: Contains Duplicate using Python. At first, I tried the brute-force approach by comparing each element with every other element using nested loops. It works, but it’s slow when the list becomes large. Then I learned a better way using a set. A key insight: If an element is already present in the set while traversing the array, a duplicate exists. 🎯 Key Takeaway: Choosing the right data structure makes a huge difference. A Hash Set helps reduce the time complexity from O(n²) to O(n) by enabling constant-time lookups. 📈 Slowly building confidence by solving one problem at a time and learning from mistakes. #DSA #LeetCode #100DaysOfCode #HashTable #Set #ProblemSolving #Python #CodingJourney #LearningInPublic #CodeNewbie
Contains Duplicate Problem Solution with Hash Set
More Relevant Posts
-
💡 A small Python lesson from LeetCode While solving LeetCode #8 (String to Integer – atoi), I wrote two solutions that were both O(n) and logically identical. But one was faster. The reason? Not the algorithm but the way the code was written. Using elif instead of multiple if checks and avoiding extra branching made a noticeable difference. In Python, fewer condition checks = fewer instructions = better runtime. Nice reminder that Big-O isn’t everything, especially in interpreted languages. Learning moments like these are why I enjoy solving problems 😄 #Python #LeetCode #LearningInPublic #SoftwareEngineering #ProblemSolving
To view or add a comment, sign in
-
🚀 Day 19/50 – LeetCode Challenge (Python) Continuing the challenge with an array problem focused on in-place marking and efficient space usage. 📌 Problem: Find All Numbers Disappeared in an Array (Easy) 🧠 Approach: Mark visited indices in the array to track missing numbers without extra space ✨ Key Learning: In-place techniques can replace additional data structures while keeping complexity optimal Staying consistent and learning new patterns. #LeetCode #Python #DSA #Consistency #LearningInPublic
To view or add a comment, sign in
-
-
Day 64 – Counting Lines in a File using Python: Day 64 focused on counting the number of lines in a file using Python. I practiced reading file contents, using readlines() to store lines in a list, and calculating the total using len(). This exercise strengthened my understanding of file reading techniques, list handling, and efficient resource management using both the traditional method and the with statement. GitHub Code: https://lnkd.in/g3nfR4_j #Day64 #100DaysOfCode #Python #FileHandling #LearningPython #CodingJourney #DailyCoding #Consistency
To view or add a comment, sign in
-
-
Python Clarity Series – Episode 9 Topic: Dictionary get() vs Direct Access 📌 Why does this code crash sometimes? d = {"a": 10} print(d["b"]) Error ❌ KeyError Better way: print(d.get("b")) Output: None 👉 d["key"] → Throws error if key missing 👉 d.get("key") → Returns None (safe access) 💡 Smart Tip: Use .get() when key might not exist. In real-world coding, this prevents crashes. This is beyond exam — this is practical Python. Have you used .get() before? #PythonTips #CodingClarity #FutureProgrammers
To view or add a comment, sign in
-
-
🚀Day 12 -Ord() and chr() in python In Python, the ord() and chr() functions are used to convert characters to their Unicode values and vice versa. The ord() function returns the Unicode (ASCII) value of a character. The chr() function returns the character from a Unicode value. #Python #LearnPython #PythonProgramming #CodingBasics #DataScience #ProgrammingJourney
To view or add a comment, sign in
-
-
Day 49 of Python with DSA 🚀 Today’s problem helped me deeply understand how linked lists differ from arrays. When asked to splice nodes, the goal is not to create new data — it’s to manipulate pointers and reuse existing memory. The more I practice, the more I improve at writing efficient, interview-ready solutions. Discipline + consistency = growth 💪 #Day49 #Python #DSA #LinkedList #ProblemSolving #SDE#CodingJourney
To view or add a comment, sign in
-
-
Learning Python by Building Logic, Not Just Syntax Today I practiced a simple but important Python concept: list manipulation and edge-case handling. I wrote a small function that swaps the first and last elements of a list: 🔍 What this helped me understand: How Python handles indexing (0 and -1) Using tuple unpacking to swap values cleanly Why edge cases matter (empty or single-element lists) Writing logic that is safe, readable, and efficient Small exercises like this may look simple, but they build the foundations for real problem-solving, especially when working with data. Consistent practice > memorising syntax. On to the next one 💪📘 #Python #LearningByDoing #ProblemSolving #ProgrammingBasics #DataEngineeringJourney 😇
To view or add a comment, sign in
-
-
"Python is the easiest language to learn!" The tutorial: print("Hello World") ✅ Week 1: Beautiful. Clean. Simple. Week 2: Indentation error. Line 47. Week 3: Mixed tabs and spaces. Chaos. Week 4: Questioning every career decision. Nobody shows you THAT in the beginner tutorial. 😅 Python IS powerful. But "easy" is doing a lot of heavy lifting in that sentence. What was your Python breaking point? #Python #Coding #ProgrammerHumor #DevLife #CodingProblems #LearnToCode
To view or add a comment, sign in
-
-
🔗🖇️... combination of sep & end Keywords. In Python, the sep keyword in the print() function defines how multiple values are separated (default is a space), while the end keyword controls what is printed at the end of the output (default is a new line). Using sep and end together helps customize output formatting and makes printed results more readable and professional. 🚀 A simple program executed in Thinny app where we can observe step by step execution of code clearly. #Python #PythonTips #Coding #DataAnalytics #LearningPython
To view or add a comment, sign in
Explore related topics
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