[HackerRank][Python3] Triple sum
2018. 7. 16. 20:51 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/triple-sum/problem
My Solution :
#!/usr/bin/env python3 def triplets(a, b, c): a = sorted(set(a)) b = sorted(set(b)) c = sorted(set(c)) result, i, j, p, r = 0, 0, 0, 0, 0 for q in b: while i < len(a) and a[i] <= q: p += 1 i += 1 while j < len(c) and c[j] <= q: r += 1 j += 1 result += p * r return result la, lb, lc = map(int, input().split()) arra = list(map(int, input().rstrip().split())) arrb = list(map(int, input().rstrip().split())) arrc = list(map(int, input().rstrip().split())) ans = triplets(arra, arrb, arrc) print(ans)
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Making Candies (0) | 2018.07.18 |
---|---|
[HackerRank][Python3] Minimum Time Required (0) | 2018.07.17 |
[HackerRank][Python3] Pairs (0) | 2018.07.17 |
[HackerRank][Python3] Hash Tables: Ice Cream Parlor (0) | 2018.07.16 |
[HackerRank][Python3] Max Min (0) | 2018.07.16 |
[HackerRank][Python3] Greedy Florist (0) | 2018.07.16 |
[HackerRank][Python3] Luck Balance (0) | 2018.07.15 |
[HackerRank][Python3] Common Child (0) | 2018.07.15 |
최근에 달린 댓글 최근에 달린 댓글