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
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Interview Preparation Kit
  3. Triple sum

Triple sum

Problem
Submissions
Leaderboard
Discussions
Editorial
HackerRank Logo
|
  1. Prepare
  2. Interview Preparation Kit
  3. Triple sum
Exit Full Screen View
  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

Given arrays of different sizes, find the number of distinct triplets where is an element of , written as , , and , satisfying the criteria: .

For example, given and , we find four distinct triplets: .

Function Description

Complete the triplets function in the editor below. It must return the number of distinct triplets that can be formed from the given arrays.

triplets has the following parameter(s):

  • a, b, c: three arrays of integers .

Input Format

The first line contains integers , the sizes of the three arrays.
The next lines contain space-separated integers numbering respectively.

Constraints

Output Format

Print an integer representing the number of distinct triplets.

Sample Input 0

3 2 3
1 3 5
2 3
1 2 3

Sample Output 0

8 

Explanation 0

The special triplets are .

Sample Input 1

3 3 3
1 4 5
2 3 3
1 2 3

Sample Output 1

5 

Explanation 1

The special triplets are

Sample Input 2

4 3 4
1 3 5 7
5 7 9
7 9 11 13

Sample Output 2

12

Explanation 2

The special triplets are .

  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website