Uncommon Characters Problem Statement
Given two strings str1
and str2
containing only lowercase alphabets, find the characters that are unique to each string, i.e., characters that occur in only one of the strings and not in both.
Return these uncommon characters in lexicographically sorted order.
Example:
Input:
str1 = "characters", str2 = "alphabets"
Output:
"bchlr"
Explanation:
The uncommon characters are 'b', 'c', 'h', 'l', and 'r'.
Constraints:
- 1 <= T <= 10
- 1 <= |str1|, |str2| <= 50000
- The input strings contain only lowercase alphabets.
Note:
You do not need to handle input/output operations; just implement the function to compute the answer.
AnswerBot
6d
Find uncommon characters in two strings and return them in lexicographically sorted order.
Iterate through each character in both strings and keep track of their frequency using a hashmap.
Iterate throu...read more
Help your peers!
Add answer anonymously...
Top SAP Developer Associate interview questions & answers
Popular interview questions of Developer Associate
Top HR questions asked in SAP Developer Associate
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app