dimanche 16 février 2020

can i create a for loop with two variables and still have time complexity of O(n)?

say i have a for loop as

for(int i=0,j=i+1;i<n-1,j<n;j++)
{

    //some code
     if(condition)
    {
     i++;
     j=i;
    }

}

what will be the time complexity and why?

Aucun commentaire:

Enregistrer un commentaire