Back to course home
0% completed
Vote For New Content
Can we use two for loop
venkatlearning11
Dec 9, 2023
if we use this approach time complexity is high?
public int numGoodPairs(int[] nums) { int pairCount = 0; // TODO: Write your code here for(int i=0; i<nums.length; i++){ for (int j=i+1; j<nums.length; j++){ if (nums[i]== nums[j]){ pairCount++; } } } return pairCount; }
0
0
Comments
Comments
Rahul2 years ago
Yes it is O(n^2)
On this page