如何找出给定约束的时间复杂度? [已关闭]

问题描述 投票:0回答:1

我在多个 DSA 问题中看到过类似“n=1 或 n<= nums.length or n<= 105". So if the constraints are given, then how do I know the exact or estimate time complexity after seeing the constraints? Can someone explain in an easy way?

c++ data-structures time-complexity constraints
1个回答
1
投票

如果给定大小约束,则时间复杂度为 O(1)。仅当输入大小可变时才会发生非常数复杂度。

© www.soinside.com 2019 - 2024. All rights reserved.