# Time Complexity Simplified

We (Beginners) often assume; Time Complexity is the time taken for the code to run, BUT its not.

Because, Depending on the Computer ( System / OS ), and the version ( Old / Latest ), the time taken for the system to run the code differs, hence time taken is NOT time complexity ( T != Time taken )

> ***Actual Definition: The rate at which the time taken increases with respect to the Input size.***

![](https://miro.medium.com/v2/resize:fit:954/1*ssxHoXjnwbjOih7lu_SjaA.png align="left")

Source: TUF Striver’s A2Z DSA sheet

So, The question is — ? How do we calculate Time complexity of a problem? simple, It is calculated in Big-O notation → O( *time taken* )

There are THREE major rules to be followed before calculating Time complexity: *1) Always consider Worst case scenario 2) Avoid Constants 3) Avoid lower values.*

**Note**: Other than Big-O notation, there are other terms such as Theta and Omega ( Though these two terms are not particularly asked in interviews, It’s better to know they exist :)

![](https://miro.medium.com/v2/resize:fit:954/1*YpL9hu8UypoHEYDiHnHlLQ.png align="left")

**Space Complexity —** It is defined as the Memory space taken by the input in any system, Which is also calculated using Big-O notation.

> ***Space complexity = Auxiliary space ( Space taken to solve the problem ) + Input space ( Space taken to store the problem )***

you can watch the detailed explanation by Striver **TUF. Happy Learning :)**
