获得2个字符串中的最小字符数 [英] obtain minimum number of characters in 2 strings

查看:118
本文介绍了获得2个字符串中的最小字符数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出两个长度相等的字符串s1和s2。如果i等于j,则可以交换s1 [i]和s2 [j]。目标是获得字符串中最小数量的唯一字符。您需要打印max(unique_chars_in_s1,unique_chars_in_s2),这应该尽可能少。你可以执行任意数量的交换,字符串只包含小写字母。



如何有效地完成这项工作。

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.

推荐答案

你知道,我们不应该做自己的功课。而是开始这样做,每当你遇到困难时,在这里发布具体问题。
You know, we aren't supposed to do your own homework. Instead start doing it and whenever you're stuck, post specific questions here.


这篇关于获得2个字符串中的最小字符数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆