Retired

Find all pairs (retired)

166 of 5,124Rubos

Description:

You are given array of integers, your task will be to count all pairs in that array and return their count.

Notes:

  • Array can be empty or contain only one value; in this case return 0
  • If there are more pairs of a certain number, count each pair only once. E.g.: for [0, 0, 0, 0] the return value is 2 (= 2 pairs of 0s)
  • Random tests: maximum array length is 1000, range of values in array is between 0 and 1000

Examples

[1, 2, 5, 6, 5, 2]  -->  2

...because there are 2 pairs: 2 and 5

[1, 2, 2, 20, 6, 20, 2, 6, 2]  -->  4

...because there are 4 pairs: 2, 20, 6 and 2 (again)

Fundamentals
Arrays

Stats:

CreatedFeb 2, 2019
Warriors Trained8528
Total Skips146
Total Code Submissions18707
Total Times Completed5124
Java Completions675
JavaScript Completions2245
PHP Completions166
Python Completions1298
Kotlin Completions244
Ruby Completions442
C# Completions188
C Completions34
Total Stars84
% of votes with a positive feedback rating93% of 710
Total "Very Satisfied" Votes621
Total "Somewhat Satisfied" Votes76
Total "Not Satisfied" Votes13
Total Rank Assessments58
Average Assessed Rank
6 kyu
Highest Assessed Rank
1 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Rubos Avatar
  • anter69 Avatar
  • Blind4Basics Avatar
  • realfg Avatar
  • KenKamau Avatar
  • FArekkusu Avatar
  • CRYPTON Avatar
  • akvptp Avatar
  • trashy_incel Avatar
Ad