Day 24 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to find duplicate elements in a list. The goal was to detect repeated values efficiently without using nested loops. What the program does: • Takes a list of numbers • Uses a set to track seen elements • Identifies elements that appear more than once • Stores duplicate values in a separate list • Prints the duplicate elements How the logic works: 1)An empty list duplicates is created to store repeated elements 2)A set seen is initialized to track elements already encountered 3)The program iterates through each element in the list 4)If the element is already in seen, it is added to duplicates 5)Otherwise, it is added to the seen set 6)Finally, duplicates are printed (converted to set to avoid repetition in output) Example: Input: Input list: [1, 2, 2, 3, 4, 4, 5, 6, 6, 7] Output: Duplicate elements: [2, 4, 6] Why this approach is efficient: – Uses a set for O(1) average lookup time – Avoids nested loops – Time Complexity: O(n) Key learnings from Day 24: – Using sets for fast membership checking – Detecting duplicates efficiently – Writing optimized list-processing logic – Strengthening data structure fundamentals #100DaysOfCode #Day24 #Python #PythonProgramming #DataStructures #SetOperations #Algorithms #ProblemSolving #CodingPractice #LearnByDoing #ComputerScience #InterviewPrep #BTech #CSE #AIandML #VITBhopal #TechJourney
Python Duplicate Element Finder with Set Operations
More Relevant Posts
-
🚀 From Hours of Manual Work to a Few Minutes – Python Automation Magic! Recently, I built a Python script that: Reads 1300+ URLs from a .txt file Opens Google search pages for distances Extracts only the numeric distance (like 127) Prints it in the console AND saves it automatically in a .txt file All this without touching Google Sheets or APIs! 🖥️ 💡 The result? What used to take hours of manual copy-paste now takes minutes. Productivity level: 💯 This project taught me how small automations can create massive efficiency gains — something every software tester or data enthusiast should explore. 📌 Key Skills Highlighted: Python, Selenium, Regex, Automation, Data Extraction Feeling proud of turning a repetitive task into scalable, reusable code! #Python #Automation #Selenium #SoftwareTesting #Efficiency #DataExtraction #SmartWork
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟱𝟱/𝟳𝟱 | 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲 𝟳𝟱 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: 2542. Maximum Subsequence Score 𝗗𝗶𝗳𝗳𝗶𝗰𝘂𝗹𝘁𝘆: Medium 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 𝗦𝘂𝗺𝗺𝗮𝗿𝘆: You are given two arrays nums1 and nums2 of equal length and an integer k. The task is to select k indices such that the score is maximized. Score is defined as: (sum of selected elements from nums1) × (minimum of selected elements from nums2) 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: This problem is solved using a Greedy + Min Heap approach. • First, pair up elements of nums2 and nums1 as (efficiency, speed). • Sort the pairs in descending order of nums2 (efficiency). This ensures that at every step, the current nums2 value is the minimum in the chosen subsequence. • Use a Min Heap to maintain the k largest values from nums1 (speed). • Iterate through the sorted pairs: Add current speed to the heap Maintain a running sum of speeds If heap size exceeds k, remove the smallest speed When heap size equals k, compute score = sum × current efficiency Update maximum score This works because we fix the minimum (nums2) greedily and maximize the sum (nums1) using the heap. 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆 𝗔𝗻𝗮𝗹𝘆𝘀𝗶𝘀: • Time Complexity: O(n log n + n log k) Sorting: O(n log n) Heap operations: O(n log k) • Space Complexity: O(n + k) 𝗞𝗲𝘆 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆: When a problem involves maximizing a function with a minimum constraint, sort by that constraint and use a heap to optimize the remaining component efficiently. 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻 𝗟𝗶𝗻𝗸: https://lnkd.in/geqU7Ptb #Day55of75 #LeetCode75 #DSA #Java #Python #MachineLearning #DataScience #ML #DataAnalyst #LearningInPublic #TechJourney #LeetCode
To view or add a comment, sign in
-
-
𝙂𝙞𝙩 𝙘𝙤𝙢𝙢𝙖𝙣𝙙𝙨 𝙖𝙧𝙚 𝙚𝙖𝙨𝙮. 𝙂𝙞𝙩 𝙥𝙧𝙤𝙗𝙡𝙚𝙢𝙨 𝙖𝙧𝙚 𝙣𝙤𝙩. Everything works fine… until it breaks. And that’s where most developers get stuck. You can clone, commit, and push. But real challenges look like this: ➥ How do you pull without losing your work? ➥ How do you commit only what matters? ➥ How do you undo mistakes safely? ➥ How do you resolve conflicts cleanly? ➥ What do you do when your push gets rejected? This guide focuses on real Git problems you face daily and shows exactly what to do in each situation. Git isn’t about memorizing commands. It’s about knowing what to do when things go wrong. Doc Credit - Respective Owner ♻️ Repost if you found this useful 🤝 Follow Sattari Sateesh Kumar for more 👨💻 For 1:1 guidance → https://topmate.io/sateesh #python #pyspark #pysparklearning #dataengineering #sqllearning #dataengineeringinterview #azuredataengineer #bigdata #spark #datalearning #datacareer #azuredataengineering #dataengineeringjobs #linkedinlearning #dataengineeringlearning
To view or add a comment, sign in
-
Python Journey — Day 11 | Number Patterns & Advanced Logic Today I practiced different number-based pattern problems using loops and nested logic. Problems I solved : • Hollow hourglass pattern • Reverse row number triangle • Inverted number triangle • Right-aligned number triangle • Increasing number triangle • Continuous number triangle • Even number triangle • Odd number triangle • Pyramid number pattern • Pascal’s triangle I used nested loops and number logic to build different pattern structures and understand how numbers flow within patterns Today's learnings: ✅ Designing number-based patterns using loops ✅ Understanding alignment and spacing logic ✅ Generating sequences like Pascal’s triangle ✅ Improving control over nested loops ✅ Strengthening logical thinking through pattern problems Today felt interesting as I explored different ways numbers can form patterns. Thanks to Rudra Sravan kumar sir for the guidance and continuous support.. Learning daily and getting more confident 📌 Consistency > Motivation On to Day 12 #PythonJourney #Day11 #PythonFullStack #10kcoders #LearningInPublic #Patterns #ProblemSolving #CodeEveryDay #FutureDeveloper #KeepLearning #PythonDeveloper
To view or add a comment, sign in
-
Day 11 of #60DaysOfMiniProjects From writing simple scripts to building small automation tools — improving step by step. Today I built a CLI-based File Renamer using Python What this project does: • Takes a folder path as input from the user • Reads all files inside the folder • Automatically renames files sequentially (file_1, file_2, file_3…) • Preserves the original file extensions • Helps organize files quickly using automation Concepts I worked with: • Python os module for file operations • os.listdir() to read files in a folder • os.rename() to rename files • os.path.join() and os.path.splitext() • Loops and conditional statements This project helped me understand how Python can automate repetitive tasks like file management. Small automation. Practical learning. Real progress. Consistency builds confidence #Python #MiniProjects #BuildInPublic #CodingJourney #CSE #DeveloperGrowth #LearningInPublic #Automation #PythonProjects
To view or add a comment, sign in
-
Data lineage traces your data's journey from source to destination. Where did this number come from? What would break if I changed this table? Who's using this data? Good lineage answers these questions. Bad lineage makes you grep through code. Tools like dbt give you SQL lineage for free. Orchestrators like Dagster give you Python lineage. The challenge is connecting them. https://lnkd.in/ea9NGZt6
To view or add a comment, sign in
-
-
𝗣𝘆𝘁𝗵𝗼𝗻 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗣𝗮𝘁𝘁𝗲𝗿𝗻𝘀 🐍 | 𝗦𝗲𝘁𝘀 – 𝗦𝗲𝘁 𝗠𝘂𝘁𝗮𝘁𝗶𝗼𝗻𝘀 🔄 | 📅 𝗗𝗮𝘆 𝟱𝟮 🚀 Today’s task: ✅ 𝗦𝘁𝗮𝗿𝘁 𝘄𝗶𝘁𝗵 𝗮 𝘀𝗲𝘁 A. ✅ 𝗣𝗲𝗿𝗳𝗼𝗿𝗺 𝗺𝘂𝗹𝘁𝗶𝗽𝗹𝗲 𝘀𝗲𝘁 𝗼𝗽𝗲𝗿𝗮𝘁𝗶𝗼𝗻𝘀. ✅ 𝗨𝗽𝗱𝗮𝘁𝗲 𝘁𝗵𝗲 𝘀𝗲𝘁 𝗱𝗶𝗿𝗲𝗰𝘁𝗹𝘆. ✅ 𝗙𝗶𝗻𝗮𝗹𝗹𝘆 𝗽𝗿𝗶𝗻𝘁 𝘁𝗵𝗲 𝘀𝘂𝗺 𝗼𝗳 𝗲𝗹𝗲𝗺𝗲𝗻𝘁𝘀. Operations used: • update() • intersection_update() • difference_update() • symmetric_difference_update() Simple? Only if you understand set mutation vs set operation. Core idea from the code: Instead of creating new sets, these operations modify the original set directly. Example: A.update(B) → adds elements of B into A A.intersection_update(B) → keeps only common elements A.difference_update(B) → removes elements present in B A.symmetric_difference_update(B) → keeps elements not common in both 💡 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆: Mutation operations are important when: • You want memory-efficient updates • You want to modify the original dataset • You want faster in-place operations Because strong Python developers don’t just know operations. They understand when data is modified vs copied. Cleaner logic. Better performance. #Python #Sets #InterviewPrep #HackerRank #DataStructures #ProblemSolving #DailyCoding #Consistency
To view or add a comment, sign in
-
-
🚀 Day 18 of Consistency | #75DaysLeetCodeChallenge 🧠 Today’s Problem : Valid Parentheses (#20) 💡 Key Learning: This problem builds a strong foundation in using a stack data structure to validate matching patterns in strings. ⚡ Approach: Use a stack to track opening brackets Create a mapping of closing → opening brackets Traverse the string → If opening bracket → push to stack If closing bracket → check top of stack → pop if valid Return true if stack is empty at end 🧠 Why this works: Ensures correct order of brackets Stack follows LIFO → perfect for matching pairs Efficient solution → O(n) time, O(n) space 🔥 Result : ✔️ Runtime: 0 ms (Beats 100%) 📈 This is a fundamental problem for mastering stacks and parsing logic. A big thanks to Shivam Singh, Nikhil Yadav & Akshat Tiwari for this amazing challenge 🙌 Consistency is compounding. Keep going. 💪 #Day18 #LeetCode #DSA #CodingJourney #100DaysOfCode #Python #Stack #Consistency
To view or add a comment, sign in
-
-
🚀Day 12 of #75DaysofLeetcode LeetCode #11 – Container With Most Water (Medium) Today I solved the classic Two Pointer problem: Container With Most Water. 🔎 Problem Summary: Given an array height, each element represents a vertical line. The goal is to choose two lines such that together with the x-axis they form a container that holds the maximum amount of water. 💡 Key Insight: Instead of checking all pairs (O(n²)), we can use the Two Pointer Technique: ✔ Start with one pointer at the beginning and one at the end ✔ Calculate the container area using area = min(height[left], height[right]) * (right - left) ✔ Move the pointer pointing to the smaller height ✔ Keep track of the maximum area ⚡ Optimal Complexity: ⏱ Time Complexity: O(n) 📦 Space Complexity: O(1) 💻 Python Implementation: from typing import List class Solution: def maxArea(self, height: List[int]) -> int: left, right = 0, len(height) - 1 max_water = 0 while left < right: area = min(height[left], height[right]) * (right - left) max_water = max(max_water, area) if height[left] < height[right]: left += 1 else: right -= 1 return max_water 📚 This problem reinforced how two pointers can reduce a brute force problem from O(n²) to O(n). Consistency in solving problems daily is slowly improving my problem-solving skills and algorithmic thinking. 💪 #LeetCode #DSA #Python #TwoPointers #ProblemSolving #CodingPractice #100DaysOfCode
To view or add a comment, sign in
-
-
🔍 Why do we use id-1 when accessing data using iloc in Pandas? While building a small Django REST API to read data from a CSV file, I came across an interesting concept in Pandas indexing. In Pandas, the iloc function is used to access rows based on integer index positions. Example: row = df.iloc[id-1] 📌 Why id-1? Because Pandas indexing starts from 0, but in APIs users usually think in terms of 1, 2, 3... Example dataset: IndexYearIndustry02024Agriculture12024Manufacturing22023Construction API request: /api/1 User expectation → First row But in Pandas: df.iloc[0] → First row df.iloc[1] → Second row So we convert the user input to the correct index: row = df.iloc[id-1] This small adjustment ensures the API returns the correct row from the CSV file. 💡 Key takeaway: User input often starts from 1, but programming indexes start from 0. #Python #Django #Pandas #RESTAPI #DataEngineering #BackendDevelopment
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