UtilityToolsLab

© 2026 UtilityToolsLab. Built and maintained by the UtilityToolsLab Team.

Free eBooks·About·Changelog·Privacy Policy·Terms of Service·Report a bug
HomeCompetitive ProgrammingComplexity Calc

Related Tools

Code FormatterMatrix GeneratorBit VisualizerBitmask PlannerPrime FactorsMEX CalcInterval MergerMatrix RotationPBDS GeneratorSegment TreeGraph VisualizerStress TesterModulo CalcConvex HullPath FinderOffline JudgeBig-O AnalyzerCombinatoricsDP Table BuilderExtended GCDSieve VisualizerBinary SearchSorting VisualizerSparse Table RMQUnion-Find DSU

Time & Space Complexity

Estimate Big-O operations and runtime for any N. Interactive reference table for all complexity classes from O(1) to O(N!).

You Might Also Like

All Competitive Programming

Code Formatter

Format and beautify C++, Java, and Python code with consistent indentation. 100% client-side — no code leaves your browser.

Matrix Generator

Generate grid/matrix inputs for competitive programming. Random, zeros, identity, or sequential fill. Outputs in multiple formats.

Timestamp

Convert Unix timestamps to human-readable dates and convert dates back to Unix time. Live clock with ISO 8601, UTC, and local formats.

Bitmask Planner

Input set size N (≤12). Visualize all 2^N bitmasks, submask iterations, and generate ready-to-paste C++ DP skeleton.

“10 to the 8th operations per second” is the rule of thumb every competitive programmer learns and the reason so many of them get a surprise verdict. A hash map lookup and an array read are both one operation in Big-O and differ by roughly 3 times in wall clock; the same loop in CPython rather than C++ differs by around 40. The Time and Space Complexity Calculator multiplies those factors in rather than pretending one number covers everything.

Pick an input size, a language, a data structure and a time limit, and each of 9 complexity classes reports an estimated running time and a verdict band. SAFE means under 40% of the limit, RISKY means up to 90%, and TLE means over. Bands rather than a tick and a cross, because the interesting answer is usually the middle one.

Everything is arithmetic in the page. Nothing is compiled, nothing is benchmarked, and no code is uploaded. The estimate is a model, and the model is stated on screen so you can argue with it.

What Each Multiplier Represents

  • Languages are scaled against a C++ tight loop at 1. Java is 2.5 for bounds checks and object overhead, PyPy is 6, and CPython is 40 for per-operation bytecode dispatch.
  • Structures are scaled against sequential array access at 1. A hash map is 3, an ordered map or segment tree is 9 because each level is a pointer chase into a cache miss, and recursion is 4 for call frames and unpredictable branches.
  • Random array access carries the heaviest structure multiplier at 20, and it is the one with no asymptotic penalty at all. That is pure memory latency once the data no longer fits in cache, which is exactly the cost Big-O is blind to.
  • The baseline rate is 1 billion cheap operations per second, deliberately higher than the traditional 10 to the 8th, since the multipliers now carry the pessimism that the old constant was hiding.
  • Time limits from 1 to 5 seconds cover the usual judge settings, and changing the limit rebands every row at once without recomputing the operation counts.

The Method Behind the Estimate

  • Effective time is the raw operation count multiplied by the structure factor, multiplied by the language factor, divided by the baseline rate. Three numbers and a division.
  • At N of 100,000, an O(N²) algorithm is 10 billion raw operations, which is 10 seconds in C++ on arrays and 400 in CPython. Both are a fail, but only one is fixable by micro-optimising.
  • At N of 1,000,000, O(N log N) is about 20 milliseconds in C++ on arrays. Move that to CPython with an ordered map and the same asymptotic work takes over 7 seconds, which is the gap that decides contests.
  • Counts above roughly 10 to the 21st render as ∞ (too large) rather than a meaningless figure, and the exponential and factorial classes cap their exponents at 60 and 20 so the arithmetic stays finite.
  • Operation counts are shown in K, M, B, T and P units so that two classes an order of magnitude apart are visibly so.

Accuracy of a Wall-Clock Guess

  • Constant factors inside your own code are invisible to this model. A modulo in an inner loop, a division, or an allocation per iteration can each cost more than the structure multiplier being applied.
  • Big-O hides its own constants too. Two O(N log N) sorts can differ by 3 times, and the notation cannot tell you which you wrote.
  • Judge hardware varies, and so does compiler version and optimisation flag. Treat a RISKY band as genuinely uncertain rather than as a near miss.
  • Java carries a JIT warm-up cost that this flat multiplier cannot represent, so short-running Java solutions are penalised more than they deserve and long-running ones less.
  • The multipliers are conventional community heuristics, not measurements from a lab. They are right about the ordering and approximate about the size.

Runtime profile — the same Big-O class can differ 10-40× depending on these three settings

C++ (-O2): Reference baseline — tight loops, no bounds checks.  · Array, sequential: Prefetcher-friendly — ~1 cycle/element amortized.

ComplexityNameOps (N=1,000)Est. TimeVerdictMax Safe N
O(1)Constant~1<1msSAFE≥2×10⁹
O(log N)Logarithmic~10<1msSAFE≥2×10⁹
O(N)Linear~1.0K<1msSAFE1,000,000,000
O(N log N)Linearithmic~10.0K<1msSAFE39,620,077
O(N√N)Sqrt-linear~31.6K<1msSAFE1,000,000
O(N²)Quadratic~1.0M1msSAFE31,622
O(N³)Cubic~1.0B1.00sTLE1,000
O(2^N)Exponential~1152.9P∞TLE29
O(N!)Factorial~2432.9P∞TLE12

Model: effective time = (N-dependent operation count) × structure multiplier × language multiplier, measured against a 1e+9 op/sec C++ baseline. SAFE = under 40% of the time limit, RISKY = 40–90% (passes on your machine, dies on a colder judge core or a hack test), TLE = over 90%. Pick the profile that actually matches your solution — a segment tree is not a flat array, and CPython is not C++.