𝗗𝗮𝘆 𝟮𝟵/𝟭𝟬𝟬 | 𝗟𝗲𝗻𝗴𝘁𝗵 𝗼𝗳 𝗟𝗮𝘀𝘁 𝗪𝗼𝗿𝗱 Day 29 ✅ — One day away from a full month. Sometimes simple is powerful. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 #𝟱𝟴: Length of Last Word (Easy) 𝗪𝗵𝗮𝘁 𝗖𝗹𝗶𝗰𝗸𝗲𝗱: Find the length of the last word in a string. Sounds simple, but edge cases make it interesting: Trailing spaces: "Hello World " Leading spaces: " Hello" Multiple spaces between words The efficient approach? 𝗧𝗿𝗮𝘃𝗲𝗿𝘀𝗲 𝗳𝗿𝗼𝗺 𝘁𝗵𝗲 𝗲𝗻𝗱. Skip trailing spaces, count characters until you hit another space. 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: 👉 Start from the end of the string 👉 Skip all trailing spaces 👉 Count characters until next space 👉 Return count Time complexity: O(n), Space complexity: O(1) One pass. No split(). No extra space. 𝗠𝘆 𝗥𝗲𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻: Easy problems teach you to handle edge cases cleanly. String manipulation might seem basic, but it's tested in every coding interview. The difference between junior and senior developers? Handling edge cases without being told. 29 days in, and I'm paying attention to the details that matter. 𝗖𝗼𝗱𝗲: https://lnkd.in/gBXpSzgy 𝟮𝟵 𝗱𝗮𝘆𝘀. 𝗧𝗼𝗺𝗼𝗿𝗿𝗼𝘄 𝗺𝗮𝗿𝗸𝘀 𝗼𝗻𝗲 𝗳𝘂𝗹𝗹 𝗺𝗼𝗻𝘁𝗵. Almost there. Consistency compounds. 𝗗𝗮𝘆 𝟮𝟵/𝟭𝟬𝟬 ✅ | 𝟳𝟭 𝗺𝗼𝗿𝗲 𝘁𝗼 𝗴𝗼! #100DaysOfCode #LeetCode #StringManipulation #EdgeCases #CodingInterview #Java #Algorithms #SoftwareEngineer #ProblemSolving #CleanCode #TechnicalInterview #Programming #DataStructures #TimeComplexity #TechCareers

To view or add a comment, sign in

Explore content categories