Day 10 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to merge two sorted lists into a single sorted list. The goal was to combine both lists efficiently while maintaining the sorted order — similar to the merging step in Merge Sort. What the program does: • Takes two already sorted lists as input • Compares elements from both lists one by one • Adds the smaller element to a new list • Appends any remaining elements after comparison • Returns the final merged sorted list How the logic works: Two pointers (i and j) are initialized to track positions in both lists A while loop runs until one of the lists is fully traversed The elements at index i and j are compared The smaller element is added to the merged list The corresponding pointer is incremented After the loop, any remaining elements from either list are appended using extend() Example: List 1: [1, 3, 5, 7] List 2: [2, 4, 6, 8] Output: Merged sorted list: [1, 2, 3, 4, 5, 6, 7, 8] Key learnings from Day 10: – Understanding the two-pointer technique – Applying comparison-based logic efficiently – Learning the core idea behind Merge Sort – Writing clean and structured functions #100DaysOfCode #Day10 #Python #PythonProgramming #DataStructures #Algorithms #TwoPointerTechnique #CodingPractice #LearningInPublic #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney
Python Merge Two Sorted Lists Efficiently
More Relevant Posts
-
Day 11 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to find all pairs in a list that add up to a given target sum. The goal was to solve this efficiently without using nested loops. What the program does: • Takes a list of numbers and a target sum as input • Uses a set to track previously seen numbers • Finds pairs whose sum equals the target value • Returns all valid pairs How the logic works: An empty list pairs is created to store valid pairs A set seen is initialized to keep track of visited numbers The list is traversed one element at a time For each number, its complement is calculated as: complement = target_sum - num If the complement already exists in the set, a pair is formed The current number is added to the set for future comparisons After traversal, all valid pairs are returned Example: Numbers: [1, 2, 3, 4, 5, 6] Target Sum: 7 Output: Pairs with sum 7: [(3, 4), (2, 5), (1, 6)] Key learnings from Day 11: – Using sets for efficient lookups – Reducing time complexity from O(n²) to O(n) – Applying complement logic – Writing optimized and clean Python functions #100DaysOfCode #Day11 #Python #PythonProgramming #DataStructures #Algorithms #HashSet #ProblemSolving #CodingPractice #LearningInPublic #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
Day 29 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to find the maximum occurring character in a string. The goal was to count the frequency of each character and determine which one appears the most. What the program does: • Takes a string as input • Counts the frequency of each character using a dictionary • Tracks the character with the highest occurrence • Handles edge cases like an empty string • Returns the most frequent character How the logic works: 1)A dictionary char_counts is used to store character frequencies 2)The program iterates through each character in the string 3)For every character, its count is updated using .get(char, 0) + 1 4)After counting, another loop checks which character has the highest frequency 5)The character with the maximum count is stored and returned 6)If the string is empty, the function returns None Example: Input: "hello world" Output: Maximum occurring character → l Input: "program" Output: Maximum occurring character → r Why this approach works well: – Uses dictionary for fast lookups – Time Complexity: O(n) – Efficient way to track frequencies Key learnings from Day 29: – Using dictionaries for frequency counting – Iterating through strings efficiently – Handling edge cases in programs – Strengthening string manipulation logic #100DaysOfCode #Day29 #Python #PythonProgramming #StringManipulation #Algorithms #ProblemSolving #CodingPractice #DataStructures #InterviewPrep #LearnByDoing #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
Day 17 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to count the number of vowels and consonants in a given string. The goal was to practice string traversal and character classification. What the program does: • Takes a string input from the user • Converts the string to lowercase for consistency • Checks each character individually • Counts vowels and consonants separately • Returns both counts How the logic works: A function count_vowels_consonants(string) is defined Two strings are created: – One containing all vowels (aeiou) – One containing all consonants Two counters are initialized to 0 The program loops through each character in the string If the character is in the vowel string, vowel count increases If the character is in the consonant string, consonant count increases The function returns both counts Example: Input: my name is SATISH KUMAR Output: Vowels: 7 Consonants: 12 Key learnings from Day 17: – Iterating through strings – Using conditional statements effectively – Handling case sensitivity with .lower() – Strengthening basic string manipulation skills #100DaysOfCode #Day17 #Python #PythonProgramming #StringManipulation #ProblemSolving #CodingPractice #LogicBuilding #LearnByDoing #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
Day 12 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to convert a decimal number into its binary representation without using built-in functions like bin(). The goal was to understand how number base conversion works internally. What the program does: • Takes a decimal number as input • Uses division and modulo operations • Builds the binary representation manually • Returns the final binary number as a string How the logic works: An empty string binary is initialized to store the result A while loop runs as long as the number is greater than 0 The remainder when dividing by 2 (n % 2) is calculated The remainder is added to the front of the binary string The number is reduced using integer division (n // 2) The loop continues until the number becomes 0 The final binary string is returned Example: Input - 34 Output - Binary representation of 34 is: 100010 Key learnings from Day 12: – Understanding number system conversion – Using modulo and integer division effectively – Building logic step-by-step without built-in shortcuts – Strengthening fundamental programming concepts #100DaysOfCode #Day12 #Python #PythonProgramming #NumberSystems #BinaryConversion #ProblemSolving #CodingPractice #LearnByDoing #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
Day 14 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to find the common elements between two lists using sets. The goal was to solve the problem efficiently without using nested loops. What the program does: • Takes two lists as input • Converts both lists into sets • Uses set intersection to find common elements • Converts the result back into a list • Prints the common elements How the logic works: Two lists are defined with numeric values Both lists are converted into sets using set() The intersection operator & is used to find common elements The resulting set is converted back into a list The final list of common elements is displayed Example: List 1:[1, 2, 3, 4, 5] List 2:[4, 5, 6, 7, 8] Output: Common elements:[4, 5] Key learnings from Day 14: – Understanding set operations in Python – Using intersection (&) efficiently – Avoiding nested loops for better performance – Writing clean and optimized code #100DaysOfCode #Day14 #Python #PythonProgramming #SetOperations #DataStructures #ProblemSolving #CodingPractice #LearnByDoing #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
Day 31 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to remove all vowels from a given string. The goal was to practice string traversal and filtering characters based on conditions. What the program does: • Takes a string as input • Checks each character in the string • Removes vowels (a, e, i, o, u) in both lowercase and uppercase • Builds a new string without vowels • Returns the final filtered string How the logic works: 1)A string vowels is defined containing all vowel characters 2)An empty string result_string is created to store the result 3)The program loops through each character in the input string 4)If the character is not a vowel, it is added to result_string 5)The process continues until all characters are checked 6)Finally, the filtered string is returned Example: Input: "Hello World" Output:"Hll Wrld" Another example: Input: "AEIOUaeiou" Output: "" (All characters are vowels) Why this approach works well: – Simple and easy to understand logic – Efficient single-pass traversal – Time Complexity: O(n) Key learnings from Day 31: – Iterating through strings – Filtering characters based on conditions – Working with string concatenation – Strengthening string manipulation fundamentals #100DaysOfCode #Day31 #Python #PythonProgramming #StringManipulation #ProblemSolving #CodingPractice #Algorithms #LearnByDoing #ComputerScience #ProgrammingJourney #DeveloperGrowth #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
🚀 Day 52 of My Python & DSA Journey Today I revisited Complement of Base 10 Integer on LeetCode — but this time with a more optimized bit manipulation approach! 🔍 Problem Overview: Find the complement of a number by flipping all bits in its binary form. 🧠 Optimized Approach: Instead of converting to binary string, I used bitwise operations: • Create a mask with all bits set to 1 (same length as the number) • Use XOR (^) to flip the bits directly • Special case: when n = 0, return 1 👉 Formula used: (mask - 1) ^ n ⚡ Why this is better: • Avoids string conversion • Works directly on bits (more efficient) • Cleaner and more optimal solution 📊 Complexity: • Time Complexity: O(log n) • Space Complexity: O(1) 💡 Key Learnings: • Deepened understanding of bitwise operators • Learned how to build bit masks dynamically • Understood difference between basic vs optimized solutions Under the Guidance of : Rudra Sravan kumar and Manoj Kumar Reddy Parlapalli #Day52 #Python #LeetCode #BitManipulation #DataStructures #Algorithms #CodingJourney #100DaysOfCode 🚀
To view or add a comment, sign in
-
-
Day 18 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to find the longest word in a given sentence. The goal was to practice string manipulation and comparison logic. What the program does: • Takes a sentence as input • Splits the sentence into individual words • Compares the length of each word • Stores the longest word found • Prints the final result How the logic works: A sentence is defined as a string The sentence is split into a list of words using .split() A variable longest_word is initialized as an empty string The program loops through each word in the list If the length of the current word is greater than or equal to the stored word, it updates longest_word After the loop ends, the longest word is printed Example: Input sentence: The quick orange fox jumps over the lazy dog Output: Longest word: orange Key learnings from Day 18: – Using .split() for string processing – Comparing string lengths – Iterating through lists efficiently – Strengthening logical thinking skills #100DaysOfCode #Day18 #Python #PythonProgramming #StringManipulation #ProblemSolving #CodingPractice #LogicBuilding #LearnByDoing #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
#Day_62 of of learning with Skill Shikshya. Today I learned about loops in Python, a concept that makes coding much more efficient and powerful. Loops allow us to run the same block of code multiple times without writing it again and again, which is especially useful when working with large amounts of data. I explored how for loops can be used to iterate through lists, strings, and other data structures, and how while loops run based on conditions. As I practiced, I also understood how to control the flow of loops using statements like break and continue. This concept made me realize how important automation is in data analysis. Instead of manually repeating tasks, loops help process data faster and more effectively. Step by step, I am building the skills needed to handle real-world datasets with confidence. #100daysoflearning #DataAnalyst #Learningjourney
To view or add a comment, sign in
-
One thing that has become clearer over the past few days is that the concepts in Python rarely exist on their own. Earlier in this challenge, many of the ideas appeared as separate pieces. Variables were introduced as a way to store information. Data structures helped organize that information. Conditions allowed decisions to be made. Loops repeated actions. Functions grouped instructions so they could be reused. Individually, each concept seemed straightforward. But when writing even a small program, those ideas begin to interact in ways that make the structure of the program more visible. A function might contain a condition that determines which path to take. A loop might call that function repeatedly while moving through a collection of values. The data being processed might be stored in a list, dictionary, or another structure designed to keep related information together. In that moment, the concepts stop feeling like isolated tools. They start behaving more like parts of a system. What initially looked like a set of separate rules begins to reveal a pattern: programming is often about combining small pieces of logic so they work together consistently. Variables hold the information. Structures organize it. Conditions evaluate it. Loops repeat the process. Functions keep the logic manageable. None of these pieces are especially powerful on their own. But when they begin to interact, they form the basic framework through which programs operate. Understanding that interaction has probably been one of the most interesting parts of this challenge so far. Day 29 / 30. #30DaysOfDataScience #Python #LearningInPublic #ProgrammingLogic
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