How would I compute the time complexity of this algorithm? The outer for loop runs n times. The inside for loop runs n-1, n-2, n-3, n-4, ... n-n times after each iteration.
/*
* isUniqueBrute - This algorithm uses the brute force approach by comparing each character
* in the string with another. Only a single comparison is made per pair of characters.
*/
bool isUniqueBrute(string str)
{
char buffer;
for (int i = 0; i < str.length(); i++)
{
for (int j = i+1; j < str.length(); j++)
{
if (str[i] == str[j])
return false;
}
}
return true;
}