1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
var numIdenticalPairs = function(nums) { let end = nums.length-1; let start = 0; let total = 0; while(start != nums.length-1) { if(nums[start] === nums[end]) { total++; } end--; if(end == start) { end = nums.length-1; start++; } } return total; };
|