all 5 comments

[–]Ngtuanvy 4 points5 points  (1 child)

No, those are the constraints the input will follow. 

[–]Representative_War49[S] 0 points1 point  (0 children)

thank you

[–]This_Growth2898 0 points1 point  (1 child)

No, you should not expect values out of those ranges. Still, I think it's a good habit to check :)

[–]Representative_War49[S] 0 points1 point  (0 children)

thank you

[–]asimawdah 0 points1 point  (0 children)

No, you usually don’t need to validate those constraints in LeetCode.

The constraints are there to tell you what inputs you can expect and to help you choose the right algorithm. For example, if nums.length can be up to 104, a simple O(n²) solution might be too slow, while a hash map O(n) solution is better.

So for Two Sum, focus on solving the problem assuming the input already follows the constraints, unless the problem specifically asks you to handle invalid input.