描述:
给出两个字符串a,b,返回 短+长(倒序)+短。如果a,b长度相等,则返回b+a(倒序)+b。a,b可能为空。
例如:
ShorterReverseLonger(“abc”, “defgh”) => “abchgfedabc”
CodeWar:
using System.Linq;
class ReverseLonger
{
public static string ShorterReverseLonger(string a, string b)
{
if(a == null) a = string.Empty;
if(b == null) b = string.Empty;
return a.Length < b.Length ? a + string.Concat(b.Reverse()) + a : b + string.Concat(a.Reverse()) + b;
}
}