In programming we face various situations where we are required to make use of intermediate STL containers as the following example depicts:
while(true)
{
set < int > tempSet;
for (int i = 0; i < n; i ++)
{
if (m.size() == min && m.size() <= max)
{
tempSet.insert(i);
}
}
//Some condition testing code
}
Or
set < int > tempSet;
while(true)
{
for (int i = 0; i < n; i ++)
{
if (m.size() == min && m.size() <= max)
{
tempSet.insert(i);
}
}
tempSet.clear();
//Some condition testing code
}
Which approach is better in terms of time and space complexity considering the present state of C++ compliers?