Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Using nested for loop

Jay

Apr 25, 2024

class Solution { numGoodPairs(nums) { let pairCount = 0; for(let i = 0; i < nums.length; i++) { for(let j = i + 1; j < nums.length; j++) { if (nums[i] == nums[j]) pairCount++; } } return pairCount; } }

1

0

Comments
Comments