# Efficient one algorithm of these two algorithms

Both of these algorithms are giving same output but the first one takes nearly double time (&gt;.67) compared to second one (.36). How is this possible? Can you tell me the time complexity of both algorithms? If they're the same, why is the time different?

Both of these algorithms are giving same output but the first one takes nearly double time (>.67) compared to second one (.36). How is this possible? Can you tell me the time complexity of both algorithms? If they're the same, why is the time different?

1st algorithm:

``` for (int i =0 ;i<n;i++){
cin>>p[i];
if(i>0){
if(p[i-1]>p[i]){
cout<<p[i]<<" ";
}
else{
cout<<"-1"<<" ";
}
}
}
```

2nd algorithm:

```for (int i =0 ;i<n;i++){
cin>>p[i];

```}
for (int i =0 ; i&lt;n-1;i++){
if(p[i]&gt;p[i+1]){
cout&lt;&lt;p[i]&lt;&lt;" ";
}
else{
cout&lt;&lt;"-1"&lt;&lt;" ";
}
}``````

## C/C++ vs. Rust: A developer’s perspective

In this post, you'll see the difference between Rust and C/C++ in a developer’s perspective

## Variable Introduction in C#[Bangla]

ＬＩＫＥ | ＣＯＭＭＥＮＴ | ＳＨＡＲＥ | ＳＵＢＳＣＲＩＢＥ A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a speci...