[Algorithm] 8 week(2.28 ~ 3.6) 2/3

Dev_min·2022년 3월 1일
0

algorithm

목록 보기
23/157

2176. Count Equal and Divisible Pairs in an Array


var countPairs = function(nums, k) {
    let count = 0;
    for(let i = 0; i < nums.length; i++){
        for(let j = i + 1; j < nums.length; j++){
            if(nums[i] === nums[j]){
                if((i * j) % k === 0){
                    count = count + 1;
                }
            }
        }
    }
    
    return count;
};
profile
TIL record

0개의 댓글