Day 22: Finding Common Prefix in Strings with Java

Day 22/100: Longest Common Prefix 📏 Today's challenge was about finding the common starting thread in an array of strings. The Logic: Vertical Scanning Instead of comparing whole words, I looked at them character by character across the entire list. If "flower", "flow", and "flight" all have 'f' and 'l' at the start, that's our prefix. As soon as a mismatch happens, we cut the string and return the result. Complexity: O(S) where S is the sum of all characters in all strings. #100DaysOfCode #Java #DSA #Strings #CodingJourney #Day22 #LearnInPublic

  • text

To view or add a comment, sign in

Explore content categories