Fácil20 pts
Beautiful Triplets
Traducción al español en progresoEl contenido detallado de esta lección aún se está traduciendo. Mientras tanto, se muestra en inglés.
Count beautiful triplets: three indices i < j < k where arr[j] - arr[i] = d and arr[k] - arr[j] = d. The array is strictly increasing. Example: arr=[1,2,4,5,7,8,10], d=3 → Triplets: (1,4,7) with values (1,4,7), (2,5,8) with values (2,5,8), (4,7,10) with values (4,7,10) → Answer: 3
Entrada
First line: n d (space-separated). Second line: n space-separated integers (the array).
Salida
A single integer: the count of beautiful triplets.
Ejemplo
7 3 1 2 4 5 7 8 10
Esperado
3
Loading editor…
Resultado
Sin salida aún. Ejecuta tu código para ver resultados.