When you implement a function, how do you determine and explain its time complexity?
Implement count_pairs(nums, target) and explain the time and space complexity of your approach. Return the number of index pairs (i, j) where i < j and nums[i] + nums[j] == target.
The input is an array of integers and an integer target. The output is an integer count. Account for duplicate values at different indices.
def count_pairs(nums, target):