Compare the Triplets
//leveraging True and False into increments
for a, b in zip(alice, bob):
score[0] += a > b
score[1] += a < b
Compare the Triplets
//leveraging True and False into increments
for a, b in zip(alice, bob):
score[0] += a > b
score[1] += a < b
beautiful triplets hackerrank solution in python
def beautifulTriplets(d, arr):
a = set(arr)
return len([1 for i in arr if i+d in a and i+d*2 in a])
n,d = map(int,input().split())
arr = list(map(int,input().split()))
print(beautifulTriplets(d, arr))
hackerrank compare the triplets
func compareTriplets(a []int32, b []int32) []int32 {
var arr []int32
var alice, bob int32
for i, _ := range a {
if a[i] > b[i] {
alice++
} else if a[i] < b[i] {
bob++
}
}
data := append(arr, alice, bob)
return data
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us