| about | help | code help+videos | done | prefs |
public String conCatShortestFirst(String s1, String s2)
int len1 = s1.length();
int len2 = s2.length();
String s = s1 + s2; // default: s1 is shorter
if (len2 < len1) {
s = s2 + s1; // if s2 is shorter!
}
return s;
conCatShortestFirst("ab", "c") → "cab" conCatShortestFirst("123", "45678") → "12345678" conCatShortestFirst("Downtown", "Magnets") → "MagnetsDowntown" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 7
Copyright Nick Parlante 2017 - privacy