Q- http://www.codechef.com/problems/PLAYFIT
A- http://www.codechef.com/viewsolution/2464885
i guess this is the problem code,
while(h != n)
{
l=(h+1);
while(l != n)
{
if(goals[l] > goals[h] && (goals[l]-goals[h]) > diff)
{
diff=goals[l]-goals[h];
}
l++;
}
h++;
}
i tried using both for and while loop, but as obvious, it doesn't change anything. Please suggest me how to shorten this code snippet or get rid of TLE anyhow.