## Problem:

Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length 0).

comboString("Hello", "hi") → "hiHellohi"
comboString("hi", "Hello") → "hiHellohi"
comboString("aaa", "b") → "baaab"

## Solution:

public String comboString(String a, String b) {
int lenA = a.length();
int lenB = b.length();

if (lenA > lenB)
return b+a+b;
else
return a+b+a;
}

1. Nice...............

2. public String comboString(String a, String b) {
return a.length() < b.length() ? a+b+a : b+a+b;
}

1. Perfect solution!)

3. public String comboString(String a, String b) {

String short1 = "";
String long1 = "" ;

short1 = a.length()>b.length()? b:a;
long1 = a.length()>b.length()? a:b;

return short1+long1+short1;
}

4. public String comboString(String a, String b) {

String short1 = "";
String long1 = "" ;

short1 = a.length()>b.length()? b:a;
long1 = a.length()>b.length()? a:b;

return short1+long1+short1;
}

5. public String comboString(String a, String b) {
if(a.length() > b.length()) {
return b + a + b;
}
else {
return a + b + a;
}
}

6. public String comboString(String a, String b)
{
String str ="";
int alen=a.length();
int blen=b.length();

if(alen>blen)
{
str=b.substring(0,b.length()) + a.substring(0,a.length()) + b. substring(0,b.length());
}
else
{
str=a.substring(0,a.length()) + b.substring(0,b.length()) + a. substring(0,a.length());
}

return str;

}

7. public String comboString(String a, String b) {
int s1 = a.length(), s2= b.length();
String s3;
if (s1>s2){
s3 = b+a+b;
}else{
s3 = a+b+a;
}

return s3;
}