Why the complexity is O(n^2)?

//Question Asked in Cracking the Coding Interview
//Complexity
String joinWords(String[] words) //Array of strings
{
String sentence = ""; // Empty Sentence
for (String w: words)
{
sentence = sentence + w; //Adding the sentence into the code
}
return sentence; //Return the sentense
}

Comments (1)