Day 36 of #50DaysOfCode: Uncommon Characters in Two Strings

Day 36 of my #50DaysOfCode challenge is done ✅ 📌 Problem Solved Uncommon Characters in Two Strings We were given two strings s1 and s2. Task was to find characters that are present in only one string. Not in both. Final result should be sorted 💻 Approach 🔹️Create two frequency arrays (or sets). 🔹️Traverse s1 and mark its characters. 🔹️Traverse s2 and mark its characters. 🔹️Now check each character from 'a' to 'z':   ▪️If present in only one string → include it   ▪️If present in both → skip it 🔹️Add valid characters to result string. 🔹️Sort the result. Simple comparison logic. --- 📊 Complexity Analysis Time Complexity: **O(n + m)** Space Complexity: **O(n + m)** --- 📚 What I learned today: ▫️Set/frequency based comparison is useful for string problems. ▫️Checking presence instead of count simplifies logic. ▫️Iterating over fixed character range helps in sorting automatically. ▫️Problem is more about filtering than processing. Day 36 completed. Understanding string comparison better 🚀 #50DaysOfCode #CodingChallenge #Consistency #LearningInPublic

To view or add a comment, sign in

Explore content categories