Java LeetCode: Longest Uncommon Subsequence Solution

Day 97/100 – #100DaysOfCode 🚀 | #Java #Strings #Logic ✅ Problem Solved: Longest Uncommon Subsequence I (LeetCode) 🧩 Problem Summary: Given two strings, find the length of the longest uncommon subsequence — a subsequence that appears in one string but not in the other. 💡 Approach Used: ✔ Observational / logical approach ✔ If both strings are equal, no uncommon subsequence exists ✔ If they are different, the longer string itself is the answer Why it works: A string is always a subsequence of itself If strings differ, the longer one cannot be a subsequence of the shorter ⚙ Time Complexity: O(1) 📦 Space Complexity: O(1) ✨ Takeaway: Some problems look like DP but are solved with pure logic. Always check for simple observations before overengineering. #Java #LeetCode #Strings #Logic #100DaysOfCode #CodingChallenge

  • graphical user interface, text, application, chat or text message

To view or add a comment, sign in

Explore content categories