Click here to Skip to main content
14,207,205 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Two strings s1 and s2 of equal length n are given. You can swap s1[i] and s2[j] if i is equal to j. The objective is to obtain minimum number of unique characters in the strings. You need to print max(unique_chars_in_s1,unique_chars_in_s2) and this should be as minimum as possible. you can perform any number of swaps and the string consists of lower-case alphabets only.

How can this be done efficiently.
Posted

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You know, we aren't supposed to do your own homework. Instead start doing it and whenever you're stuck, post specific questions here.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190612.1 | Last Updated 3 Aug 2015
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100