We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Combinatorics
  4. Sherlock and Pairs
  5. Discussions

Sherlock and Pairs

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

Sort 131 Discussions, By:

recency

Please Login in order to post a comment

  • alfruk
    2 weeks ago+ 0 comments
        in c++, remember to change the result variable in the main() function
    
                long long result = solve(a);
    
    0|
    Permalink
  • brewjunk
    1 month ago+ 0 comments
    from collections import Counter
    
    def solve(a):
        c = Counter(a)
        count = 0
        for i in c.values():
            count += i*(i-1)
        return count
    
    0|
    Permalink
  • dingma129
    3 months ago+ 0 comments

    a python3 solution

    from collections import Counter
    def solve(a):
        C = Counter(a)
        return sum(n*(n-1) for n in C.values())
    
    0|
    Permalink
  • rbpimenta
    4 months ago+ 0 comments

    For those who are trying in Java 8, you will need to change the given method to work with long and not int.

    You also need to change that in the main, that is automatically generated by Hacker Rank.

    0|
    Permalink
  • devcana15
    5 months ago+ 0 comments

    Can anyone help what is wrong with the following code. Only three out of 17 cases are working. https://www.hackerrank.com/challenges/sherlock-and-pairs/submissions/code/288605771

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy