我在多个 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?
如果给定大小约束,则时间复杂度为 O(1)。仅当输入大小可变时才会发生非常数复杂度。