## Why am I getting a TLE?
Usually we assume that the number of instructions that a computer can execute in one second is about k*10^8 (k is a constant).
If you want to know how many seconds your code will run, you must learn how to "estimate" your code.
Take an EZ example:
```C++
for(int i=0;i<n;++i){
for(int j=0;j<i;++j){
if(arr[i]<arr[j]){
int tmp=arr[i]; //swap
arr[i]=arr[j];
arr[j]=tmp;
}
}
}
```
For test data A:
> arr = {1,2,3,4,5}
the code will run 1+2+3..+5 times "if" operation.
But for test data B:
> arr = {5,4,3,2,1}
the code will run 1+2+3...+5 times "if" operation and 1+2+3+4 "swap" operation. The number of operations is about 3~4 times more than that of test data A!
It can be found that test case A is the best-performing case among the above codes for array length = 5, while B is the worst. Often the latter is the case with TLE on Online Judge.
Therefore, for a program, we usually estimate its "worst case" as time complexity. (Same spaces as above)
Combining the information mentioned at the beginning, we can find that for this sorting algorithm, when the input array length reaches 10^5, the execution time is about `(1+10^5)*(10^5)/2` to `(1+10^5)*(10^5)*2`, as you can see is not easy to express, which is why the k*10^8 mentioned at the beginning requires the existence of k.
`(k*10^10) / (k*10^8) = 100s, This is why this code will not pass for questions with a time limit of 1 second.`
Another EZ example of TLE:
```C++
int i = 0;
while (i >= 0) {
i++;
}
```
How it is possible to write this code? In many cases, the time complexity is good, but it is still TLE for this reason - the program will run forever.