If all the elements of the words array are all Strings of fixed length x,
public String joinWords(String[] words) {
String sentence = "";
for (String w : words) {
sentence = sentence + w;
}
return sentence;
}
Can someone explain to me how the runtime of this algorithm becomes O(xn^2) ? And how does StringBuilder or StringBuffer improve on this ?