🚀 Day 5/50 – DSA with Python Challenge Today I focused on Python String Data Structure and practiced many important concepts. 📌 What I learned & practiced today: 🔹 String creation & escape characters Single quotes, double quotes Escape sequences (\n, \\, \') 🔹 String operations Indexing (positive & negative) String comparison (<, >, ==, !=) ASCII values using ord() and chr() 🔹 String formatting % formatting format() method f-strings 🔹 String methods find(), index() startswith(), endswith() split(), join() strip(), lstrip(), rstrip() Membership operator (in) 🔹 Pattern searching in strings Finding all occurrences using find() with loop 🔹 Palindrome checking Using two-pointer technique Using slicing ([::-1]) 🔹 Anagram checking Using sorting method Using character frequency (ASCII count – optimized approach) 🧠 Key takeaway: Understanding strings deeply helps in solving many DSA problems efficiently and builds strong problem-solving fundamentals. 📈 Consistency over motivation — one day at a time. #Day5 #DSAWithPython #PythonProgramming #StringDataStructure #LearningInPublic #50DaysChallenge #ProblemSolving #CodingJourney
More Relevant Posts
-
🧠 Python Feature That Makes Type Checking Smarter: typing.Protocol Duck typing… but official 🦆✨ 🤔 The Problem 💻 Python is dynamically typed. 💻 But sometimes you want structure without inheritance. ❌ Traditional Way class Bird: def fly(self): ... def start_flying(bird: Bird): bird.fly() This forces inheritance. ✅ Pythonic Way with Protocol from typing import Protocol class Flyable(Protocol): def fly(self) -> None: ... def start_flying(obj: Flyable): obj.fly() 💫 Now ANY object with fly() works. 💫 No inheritance required 🎯 🧒 Simple Explanation 🦆 If it quacks like a duck and walks like a duck… 🦆 it doesn’t need to be a Duck class. 🦆 That’s Protocol. 💡 Why This Is Powerful ✔ Structural typing ✔ Cleaner architecture ✔ Better static analysis ✔ Used heavily in modern Python frameworks ⚡ Real Example class Drone: def fly(self): print("Flying") start_flying(Drone()) # Works! 🐍 Python believes in behavior, not hierarchy 🐍 typing.Protocol makes duck typing formal and powerful. #Python #PythonTips #PythonTricks #AdvancedPython #CleanCode #LearnPython #Programming #DeveloperLife #DailyCoding #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 2 – DSA Series Remove Duplicates from Sorted Array Solved LeetCode 26 – Remove Duplicates from Sorted Array using Python. 🧠 Problem Summary Given a sorted array nums, remove duplicates in-place such that each unique element appears only once. Return the number of unique elements k, where: • The first k elements of nums contain the unique values • The remaining elements beyond k don’t matter • No extra array allowed (O(1) space) Example: Input: [1, 1, 2] Output: k = 2 → Modified array: [1, 2, _] 💡 Approach Used (Two Pointer Technique) Since the array is sorted, duplicates are adjacent. ✔️ Initialized k = 1 (first element always unique) ✔️ Iterated from index 1 ✔️ Compared current element with previous element ✔️ When a new unique element is found: • Placed it at index k • Incremented k This ensures in-place modification without extra space. ⏱ Complexity Analysis Time Complexity: O(n) – single pass Space Complexity: O(1) – no additional data structures 🔎 Key Takeaway This problem strengthens: • Two Pointer pattern • In-place array manipulation • Understanding problem constraints carefully Continuing the DSA series — one problem at a time. 🚀 #DSA #LeetCode #Python #Algorithms #TwoPointers #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day-38 of #100DaysOfCode 🐍 Python Sorting Algorithm Challenge Today I implemented Selection Sort from scratch to sort a list of numbers provided by the user—without using any built-in sorting methods. 🔹 What is Selection Sort? Selection Sort repeatedly selects the smallest element from the unsorted portion of the list and places it at the correct position. 🔹 Concepts Practiced: ✔ Nested loops ✔ Minimum element selection logic ✔ Index tracking ✔ In-place swapping 🔹 Approach: Iterate through the list Find the minimum element in the remaining unsorted part Swap it with the current index Repeat until the list is fully sorted 🔹 Key Insight: Selection Sort has a time complexity of O(n²), making it useful for understanding sorting fundamentals rather than large datasets. Working through such algorithms builds strong foundational knowledge of sorting and array manipulation 💡 #Python #SelectionSort #SortingAlgorithms #CorePython #100DaysOfCode #Day38 #LearnPython #CodingPractice #PythonDeveloper
To view or add a comment, sign in
-
-
🚀 Day 4 – DSA Daily Series Move Zeroes (LeetCode 283) using Python. 🧠 Problem Given an integer array nums, move all 0’s to the end of the array while maintaining the relative order of the non-zero elements. Important constraints: • The operation must be done in-place • No extra array should be created Example: Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0] 💡 Approach Used the Two Pointer technique. • Maintain a pointer k to track the position for the next non-zero element • Traverse the array using index i • Whenever a non-zero element is found, swap it with the element at position k • Increment k This ensures: • Non-zero elements move to the front • Zeros automatically shift toward the end ⏱ Complexity Time Complexity: O(n) – single pass through the array Space Complexity: O(1) – in-place modification 🔎 Key Learning This problem helps strengthen: • Two Pointer pattern • In-place array manipulation • Maintaining relative order while rearranging elements Consistency is key when practicing DSA — solving one problem at a time. 🚀 #DSA #LeetCode #Python #Algorithms #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Python doesn’t have is_sorted() — and that’s intentional. If you need to validate order without re-sorting the data, this is the most efficient pattern: def is_sorted(t): return all(x <= y for x, y in zip(t, t[1:])) Why this works: - zip(t, t[1:]) compares adjacent elements - all() short-circuits on the first violation - Time complexity: O(n) - Stops early if unsorted Most developers reach for: t == tuple(sorted(t)) That’s O(n log n) and allocates memory — even if the tuple is already sorted. When validating: - Timestamps before binary search - Sorted IDs before merge operations - Monotonic sensor readings Use pairwise comparison — not sorting. Full breakdown (with benchmarks and edge cases): https://lnkd.in/gxGiudfR #Python #SoftwareEngineering #Performance
To view or add a comment, sign in
-
-
Day 11 of my Python journey 🐍✂️ List-String superpowers + slicing mastery! Text processing pro now. 📝 Unlocked: split(): string → list magic join(): list → string perfection Negative indexing: -1 = last item everywhere! Slicing with negative step: [::-1] = reverse genius Advanced slices: every nth item, custom ranges Key takeaways: "hello world".split() → ['hello', 'world'] ✅ '-'.join(['a','b','c']) → 'a-b-c' beauty! Negative step reverses sequences instantly Slicing works identically on strings AND lists! 🔄 Practiced: CSV parsers, reverse formatters, and data extractors. Text tamed! 🧹 Next: Powerful list methods incoming! ⚙️ String slicing = universal weapon! 🗡️ #Python #Day11 #SplitJoin #NegativeIndexing #ReverseSlicing #ListString #CodingJourney #100DaysOfCode #LearnInPublic #CodeNewbie #DeveloperJourney #Hyderabad #PracticeMakesProgress #PythonForBeginners
To view or add a comment, sign in
-
🧠 Python Concept That Explains Why += Can Mutate: In-place vs New Objects (__iadd__) Why does this behave differently? 👀 a = [1, 2] b = a a += [3] print(a) # [1, 2, 3] print(b) # [1, 2, 3] But: x = (1, 2) y = x x += (3,) print(x) # (1, 2, 3) print(y) # (1, 2) Same += … different result 🤯 🤔 The Reason: __iadd__ Python tries: 1️⃣ __iadd__ (in-place add) 2️⃣ else → __add__ (new object) 🧪 Lists implement __iadd__ list.__iadd__(self, other) So list is modified in place. 🧪 Tuples don’t So Python creates a new tuple. 🧒 Simple Explanation List = clay 🧱 You reshape same clay. Tuple = brick 🧱 You must make new brick. 💡 Why This Matters ✔ Mutability understanding ✔ Side-effects bugs ✔ Performance ✔ Data structures ✔ Interview classic ⚡ Key Insight id(a) == id(a += ...) True for mutable types False for immutable types 💻 In Python, += doesn’t always mean “new value”. 🐍 Sometimes it means “modify in place” 🐍 The difference comes from __iadd__. #Python #PythonTips #PythonTricks #AdvancedPython #CleanCode #LearnPython #Programming #DeveloperLife #DailyCoding #100DaysOfCode
To view or add a comment, sign in
-
-
Day 9: Mastering Type Casting in Python 🐍 Today I explored how Python handles type conversions, and it's more powerful than I initially thought! Type casting lets us convert data from one type to another, which is essential when working with user inputs, APIs, or databases. Key takeaways: Implicit vs Explicit Casting: Python automatically converts some types (like int to float), but we often need to explicitly cast data using functions like int(), str(), float(), and bool(). Real-world scenario: Converting user input (always a string) into integers for calculations, or formatting numbers as strings for display. Common pitfalls I learned to avoid: Not every string can be cast to an integer, and float to int conversion truncates decimals rather than rounding. Code snippet from today: python # User age input age = int(input("Enter your age: ")) # Converting for display price = 49.99 print(f"Price: ${str(price)}") # List to string items = ['apple', 'banana', 'cherry'] print(', '.join(items)) The journey continues! Each day brings new understanding of how Python handles data behind the scenes. #Python #FullStackDevelopment #CodingJourney #100DaysOfCode #LearningToCode #WebDevelopment
To view or add a comment, sign in
-
-
Let’s keep it simple (and a little fun today 😄) Which of the following is a valid list comprehension in Python? A) [x for x in range(5) if x % 2 == 0] B) for x in range(5): if x % 2 == 0 C) x = [range(5) if x % 2 == 0] D) list(x for x in range(5) if x % 2 == 0) 🧠 The correct answer is: 👉 A [x for x in range(5) if x % 2 == 0] This is the classic Pythonic structure: [expression for item in iterable if condition] ✨ Option D technically works and returns a list, but A is the clean, direct list comprehension syntax. Small concept. Big readability difference. Clean code isn’t about writing more… It’s about writing smarter 🔥 #Python #AI #LearningInPublic #30DayChallenge #DataAnalytics #CleanCode
To view or add a comment, sign in
-
If you've been putting off adding AI image generation to your Python stack — this is your sign. 🐍 New tutorial just published: How to Use the Stable Diffusion API with Python What you'll learn: → API authentication and setup → Generating images from text prompts → Controlling model parameters for better outputs → Production-ready code you can deploy today Stable Diffusion API integration doesn't need to be complicated. With ModelsLab's API, you're generating images in under 5 minutes — no GPU required. Full tutorial → https://lnkd.in/gSDKdZ_5 Whether you're building a creative app, automating design workflows, or just exploring generative AI — this is the foundation. Questions? Drop them in the comments 👇 #StableDiffusion #Python #GenerativeAI #API #DeveloperTutorial #MachineLearning #AIImageGeneration
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