Skip to content

dcoder201/Remove-common-characters-and-concatenate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Remove-common-characters-and-concatenate


Online Python Challenges

Given two strings s1 and s2. Modify both the strings such that all the common characters of s1 and s2 are to be removed and the uncommon characters of s1 and s2 are to be concatenated. Note: If all characters are removed print -1.

Example 1:

Input:

s1 = aacdb s2 = gafd

Output: cbgf

Explanation: The common characters of s1 and s2 are: a, d. The uncommon characters of s1 and s2 are c, b, g and f. Thus the modified string with uncommon characters concatenated is cbgf.


Example 2:

Input: s1 = abcs s2 = cxzca

Output: bsxz

Explanation: The common characters of s1 and s2 are: a,c. The uncommon characters of s1 and s2 are b,s,x and z. Thus the modified string with uncommon characters concatenated is bsxz.

Your Task: The task is to complete the function concatenatedString() which removes the common characters, concatenates, and returns the string. If all characters are removed then return -1.

Expected Time Complexity: O(N). Expected Auxiliary Space: O(Number of distinct characters). Note: N = |Length of Strings|

Constraints: 1 <= |Length of Strings| <= 104

About

Online Python Challenges

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages