What is the running time of the following piece of code ?
void function(int n){
if(n==1) return ;
for(int i=1; i<=n; i++)
for(int j=1; j<=n;j++)
break;
}
Difficulty level
This exercise is mostly suitable for students
O(n)
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Encoding and decoding a string (version 2)