Home Cp Competitive programming time Complexity
Post
Cancel

Cp Competitive programming time Complexity

Hello all, when you doing competitive programming or solving any coding questions on coding platform like leetcode, hackerearth or hackerrank then sometime you might be faced TLE error, while submitting your code on online judges. So today, I will talk about how you can train your mind before solving any coding problems and can get rid of TLE error. I’m sharing my personal experiences this might be useful for you, while solving online assessment on hackerrank and hackerearth.

For this table construction i have assumed that on average online judge will be able to finished 10^6 Instruction per second.

Range of NAllowed Time ComplexityMost Used tech
N≤10O(N!)Brute Force
N≤25O(2^N)Recursion/Brute force/Backtracking
N≤100O(N^4) 
N≤500O(N^3) 
N≤5*10^3O(N^2)2D-dp table construction/Brute force-two for loop
N≤5*10^5O(N√(N)),O(N Log(N))Sorting/Binary search
N≤10^6O(N), O(N Log(N))Prefixarray/Suffixarray/Sorting/1D-dp
N≤10^7Optimized O(N),Optimized O(N Log(N)), O(N Log(Log(n))), O(Log(N)) 
N≤10^8O(Log(N)) 
N≤10^9O(Log(N))Binary Search
N≤10^12O(√N) 
N≤10^16Optimized O(√N)Bit mapping
N≤10^18O(Log(N))Bit mapping
This post is licensed under CC BY 4.0 by the author.