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
Python Code Challenge: Longest Word Finder
More Relevant Posts
-
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 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
-
-
📌 Day 49 of #100DaysOfLeetCode 🔹 Problem: Contains Duplicate II (LeetCode 219) 💡 Problem Statement: Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that: nums[i] == nums[j] |i - j| ≤ k In simple words, check if the same number appears again within k distance in the array. ⚙ Approach: Use a HashMap (dictionary) to store the last index of each number. Traverse the array once. If the number already exists in the map: Check the distance between indices. If distance ≤ k, return True. Update the index of the number in the map. ⏱ Complexity: Time Complexity: O(n) Space Complexity: O(n) 🎯 Key Learning: Hashing helps track previously seen elements efficiently and allows solving duplicate problems in linear time instead of nested loops. #LeetCode #DSA #Python #HashMap #CodingChallenge #100DaysOfCode #ProblemSolving
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 12 of Consistency | #75DaysLeetCodeChallenge 🧠 Today’s Problem : 3Sum (#15) 💡 Key Learning: This problem teaches how to efficiently find triplets using sorting + two-pointer technique, while carefully handling duplicates. ⚡ Approach: Sort the array → fix one element (i) → use two pointers (l, r) → If sum == 0 → store triplet & skip duplicates If sum < 0 → move l++ If sum > 0 → move r-- 🧠 Why this works: Reduces complexity from O(n³) → O(n²) Avoids duplicate triplets Efficient use of sorting + two pointers 🔥 Result : ✔️ Runtime: 574 ms (Beats 75.21%) 📈 Problems like this build strong intuition for tackling complex array & pattern-based questions. Consistency is compounding. Keep going. 💪 #Day12 #LeetCode #DSA #CodingJourney #100DaysOfCode #Python #TwoPointers #Consistency
To view or add a comment, sign in
-
-
🚀 Day 1: The Foundation & The "Aha!" Moment Focus: Variables & Fundamentals Today, I officially wrote my first lines of Python after a long time, and let’s just say… it was a beautifully humbling experience. 😅 I realized that even the "simplest" tasks—like adding numbers or printing a sentence—require total precision. Python is gentle until you forget a single quote mark, and then it’s game over! What I tackled today: The Execution Flow: Understanding how Python reads code from top to bottom. The Power of Variables: They’re essentially just containers, but naming them is an art form. The Rules: Learned why (my_var) works, but (2_var) breaks everything. Data Types: Realizing that 10 (integer) and "10" (string) might look the same to us, but they are worlds apart to a computer. It’s exciting, a little frustrating, and 100% worth it. 😁 #Python #Day1 #LearningToCode #TechBeginner #CodingFromScratch
To view or add a comment, sign in
-
-
I’ve been strengthening my Python foundations by diving into NumPy with guidance from Intellipaat’s YouTube channel. This session covered the essentials: importing and installing NumPy, understanding dimensions and shapes, creating arrays (including random arrays), and working with NumPy data types. I also explored type casting and learned how to handle type casting errors — a critical skill for ensuring clean, reliable computations. I’ve documented my work and uploaded the notebook to GitHub: https://lnkd.in/djEdyFp8. Excited to keep building momentum and applying these skills to larger projects. Feedback and insights are always welcome. #NumPy #Python #DataScience #MachineLearning #Intellipaat #LearningJourney #DataScience #ComputerScience
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
-
🚀 Solved Today’s POTD (27 Feb 2026): Number of Submatrix Having Sum = X on GeeksforGeeks using Python 🐍 Problem: Given a matrix of size n × m and an integer x, find the number of square submatrices whose sum of elements equals x. Approach: 🔹 Built a 2D Prefix Sum matrix to compute submatrix sums efficiently 🔹 Iterated over all possible square sizes 🔹 Calculated each square’s sum in O(1) using prefix formula 🔹 Counted squares where sum == x This problem strengthened my understanding of: ✔️ 2D Prefix Sum technique ✔️ How to reduce repeated calculations ✔️ Matrix-based pattern recognition 💡 Time Complexity: O(n³) (Works within constraints) Every day, learning a new pattern. Consistency is turning practice into confidence 💪 #day11 #geekstreak60 #npci #geeksforgeeks #dsa #python #learning #problemsolving #codingjourney
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