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
4mo
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...
SAP Developer Associate interview questions & answers
A Developer Associate was asked 2mo agoQ. Have you worked with CDS views and implemented the RAP framework?
A Developer Associate was asked Q. What are binary trees?
A Developer Associate was asked Q. Design a calculator that performs operations on 128-bit integers.
Popular interview questions of Developer Associate
A Developer Associate was asked Q1. What are binary trees?
A Developer Associate was asked Q2. Design a calculator that performs operations on 128-bit integers.
A Developer Associate was asked Q3. How to reverse a linked list and write program to get right view of a binary tre...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

