🧩 Problem: Remove Duplicates from Array (LeetCode #26) 💡 Concept Learned: This problem taught me the importance of In-place Modification. Instead of creating a new list, I modified the original array to save memory, ensuring the first k elements are the unique ones. 🔍 Key Insight: The Memory (Set): I used a Python Set to instantly check if a number was already seen.The Writer (Pointer k): I maintained a pointer k to track where the next unique element should be placed.The Strategy: When a "new" number is found, I overwrite nums[k] and increment k. This keeps all unique values at the front of the line. 🎯 Key Takeaway: Indentation is Logic: In Python, the placement of a return statement is the difference between a finished loop and an early exit. Efficiency: Using a Set makes lookups , making the overall solution time complexity. Growth: Every bug (like a NameError or a misplaced return) is just a lesson in disguise. 📈 Slowly building confidence by solving one problem at a time and learning from mistakes. #DSA #LeetCode #100DaysOfCode #TwoPointers #ProblemSolving #Python #CodingJourney #LearningInPublic #CodeNewbie
Remove Array Duplicates with In-Place Modification
More Relevant Posts
-
Python Clarity Series – Episode 17 Topic: len() vs count() 📌 len() vs count() — students mix these often. Example list: numbers = [1, 2, 2, 3, 4] 👉 len(numbers) Output → 5 Counts total elements 👉 numbers.count(2) Output → 2 Counts occurrence of a specific value 💡 Easy way to remember: len() → length of container count() → frequency of value Example: print(len(numbers)) print(numbers.count(2)) Understanding the difference avoids wrong answers in MCQs. Which one confused you first time? #PythonConcepts #CodingBasics #ExamPreparation
To view or add a comment, sign in
-
-
Python Clarity Series – Episode 8 Topic: pass vs continue 🤯 pass vs continue — Are they same? No. 👉 pass → Does NOTHING 👉 continue → Skips to next iteration Example: for i in range(3): if i == 1: pass print(i,end="") Output: 0 1 2 Now: for i in range(3): if i == 1: continue print(i,end="") Output: 0 2 💡 Clarity Rule: pass → Placeholder continue → Control flow changer Students often think pass skips. It doesn’t. Subtle difference. Strong concept. #PythonLearning #DeepConcepts #StudentClarity
To view or add a comment, sign in
-
-
🚀 Solved Today’s POTD (28 Feb 2026): Find the Closest Pair from Two Sorted Arrays on GeeksforGeeks using Python 🐍 Problem: Given two sorted arrays and a target value x, find a pair (one element from each array) whose sum is closest to x. Approach: 🔹 Used the Two Pointer technique 🔹 Started one pointer at the beginning of arr1 and the other at the end of arr2 🔹 Compared the current sum with x and adjusted pointers intelligently 🔹 Tracked the minimum absolute difference Why this works? Since the arrays are sorted, we can move pointers strategically instead of checking all pairs — reducing time complexity from O(n*m) to O(n + m). This problem strengthened my understanding of: ✔️ Two Pointer optimization ✔️ Leveraging sorted properties ✔️ Writing efficient solutions over brute force 💡 Time Complexity: O(n + m) Daily practice. Better patterns. Sharper thinking. 💪 #day12 #geekstreak60 #npci #geeksforgeeks #dsa #python #learning #problemsolving
To view or add a comment, sign in
-
-
🚀 Day 11/30 – Defining & Calling Functions in Python Today, I learned how to write cleaner and smarter code using functions. Instead of repeating the same logic multiple times, we can define it once and reuse it whenever needed. That’s powerful. 📌 What I practiced: • Defining a function using def • Calling the function • Passing values (arguments) • Returning results Here’s a simple example I built today: . 💡 Key Takeaway: Functions make programs organized, efficient, and professional. Small concept. Big impact. Day 11 complete ✅ #Python #30DaysChallenge #LearningInPublic #ProgrammingJourney #Consistency Aditya ChaturvediJECRC UniversityYash Raj ChoudharyRaj Gehlot
To view or add a comment, sign in
-
-
Python Clarity Series – Episode 16 Topic: range() Confusion (Start, Stop, Step) 📌 range() looks simple… but many students misunderstand it. Basic form: range(start, stop, step) Example: for i in range(2, 10, 2): print(i) Output: 2 4 6 8 👉 start → where counting begins 👉 stop → where counting stops (NOT included) 👉 step → increment value ⚠️ Important rule: range() always excludes the stop value. 💡 Memory Trick: Range goes UP TO but not INCLUDING the stop value. Example: range(5) Output: 0 1 2 3 4 Students often expect 5 — but it never appears. Small detail. Big exam mistake. #PythonBasics #LoopConcepts #StudentLearning
To view or add a comment, sign in
-
-
💻 Day 44 of #100DaysOfLeetCode 🔍 Problem: Find Common Characters 🔢 LeetCode: 1002 📌 Problem Understanding: We are given a list of words. The goal is to find all characters that appear in every word in the list. ✔ If a character appears multiple times in all words, it should appear the same number of times in the result. ✔ The order of the output does not matter. 🧠 Approach: 1️⃣ Iterate through all characters from 'a' to 'z'. 2️⃣ For each character, count how many times it appears in every word. 3️⃣ Track the minimum count across all words. 4️⃣ If the minimum count is greater than zero, add that character to the result list that many times. ⚙️ Key Idea: The smallest frequency of a character across all words determines how many times it will appear in the final result. 💡 What I Learned: This problem highlights how frequency counting and minimum occurrence tracking can be used to identify common elements across multiple strings efficiently. #Day44 #100DaysOfLeetCode #LeetCode #CodingJourney #Python #DSA #ProblemSolving 🚀
To view or add a comment, sign in
-
-
What Debugging My DSA Mistakes Taught Me Recently, I realized something: The real learning didn’t happen when I got the solution right. It happened when I got it wrong. - Popped from a stack twice in one line. - Confused floor division with truncation in Python. - Stored values instead of indices and broke duplicate cases. - Used Kadane where prefix sum was required. Each mistake exposed a hidden assumption. I stopped memorizing patterns and started understanding invariants. The biggest shift wasn’t solving harder problems, it was asking better “why” questions. #DSA #Algorithms #Python
To view or add a comment, sign in
-
🚀 Day 9 of #100DaysOfCode Today’s problem: Valid Anagram ✅ 🔍 What I learned: How to check if two strings are anagrams Importance of sorting vs frequency counting Strengthened my understanding of strings & hashing concepts 💡 Approach: I used a simple and clean method: Sort both strings Compare them If equal → Anagram ✔️ 📊 Result: ✅ All test cases passed (54/54) ⏱️ Runtime: 19 ms 🔥 Key takeaway: Sometimes a simple solution is enough, but there’s always room to optimize using hash maps for better performance. Consistency > Perfection 💯 Let’s keep going! #LeetCode #DSA #CodingJourney #Day9 #Python #ProblemSolving
To view or add a comment, sign in
-
-
𝗪𝗲𝗲𝗸 𝟯 of my 𝗗𝗮𝘁𝗮 𝗦𝗰𝗶𝗲𝗻𝗰𝗲 & 𝗠L program with ParoCyber wrapped up with two solid labs on Python operators and string methods. We covered a lot of ground on arithmetic, comparison, logical, assignment, bitwise, membership, and identity operators. Each one serves a specific purpose in how Python reads and evaluates data. 💡The operators '𝙞𝙨' vs '==' were a good reminder that two values can be equal without pointing to the same object in memory. The second lab focused on string methods like split(), join(), replace(), and more. 💡One thing that stuck: strings in Python are 𝗶𝗺𝗺𝘂𝘁𝗮𝗯𝗹𝗲. Any operation returns a new string, not a modified original. Small detail, but it matters. To see the full breakdown, it's all documented on my GitHub. Link below. 🔗 https://lnkd.in/dVnTd3jS #DataScience #Python #MachineLearning #ParoCyber #LearningInPublic #CareerGrowth #WomenInTech
To view or add a comment, sign in
-
Python Clarity Series – Episode 6 Topic: = append() vs extend() List methods confusion: append() vs extend() Students think both do the same thing. They don’t. 👉 append() → Adds ONE item 👉 extend() → Adds EACH element separately Example: a = [1, 2] a.append([3, 4]) print(a) Output: [1, 2, [3, 4]] Now: a = [1, 2] a.extend([3, 4]) print(a) Output: [1, 2, 3, 4] 💡 Memory Trick: append → Attach extend → Expand Exams love this difference. Students — which one did you mix up first time? #PythonBasics #CBSE #CodingMistakes #LearnPython
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