Calculate initial velocity given distance, gravity and angle for a projectile to hit the target at uneven ground

Hello guys!
What i am looking for is a formula to calculate vertical and horizontal (or just the initial) speed for projectile to hit a target which is at a height different than launcher.
I have been looking for the answer for quite a long time and actually found solution for the same height.
94220-0height.gif
Here is the code sample for that:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PArticleProjectile : MonoBehaviour {
    [Range(10,45)]
    public int Angle = 45;
    public float gravity = 9.8F;
    public Transform Target;

    public ParticleSystem.VelocityOverLifetimeModule PartS;

	void Start ()
    {
        PartS = gameObject.GetComponent<ParticleSystem>().velocityOverLifetime;
	}
	void Update ()
    {
        Vector3 displacement = (transform.position - Target.position);
        float Vx = Mathf.Sqrt((distance * gravity) / Mathf.Sin(2 * Angle * Mathf.Deg2Rad)) * Mathf.Cos(Angle * Mathf.Deg2Rad);
        float Vy = Mathf.Sqrt((distance * gravity) / Mathf.Sin(2 * Angle * Mathf.Deg2Rad)) * Mathf.Sin(Angle * Mathf.Deg2Rad);
        PartS.x = Vx;/*SolveBallisticEquation(displacement.x, displacement.y, gravity, Angle).x;*/
        PartS.y = Vy;/*SolveBallisticEquation(displacement.x, displacement.y, gravity, Angle).y;*/
    }
}

It works perfectly when target and launcher are on the same height but it starts to deviate when i am changing altitude of either one.
By the way i want to do this via particle system(Velocity over lifetime).When i enable gravity on particles velocity over lifetime starts to behave like initial velocity.
So if anyone has some useful formulas for that i’d appreciate if you share them down in the answers.

Well i ended up solving it by myself with the help of the formula described in this forum
Here is my code sample. I hope it will help someone who is is looking for it.It has been really a pain))

 Vector2 SolveBallisticEquation(float distanceX,float distanceY,float gravity,float angle)
    {
        distanceX = Mathf.Abs(distanceX);
        float TotalSpeed;
        Vector2 Solution;
        TotalSpeed = (1/ Mathf.Cos(angle * Mathf.Deg2Rad))*Mathf.Sqrt(0.5F*distanceX*distanceX* gravity /(distanceY + Mathf.Tan(angle * Mathf.Deg2Rad) * distanceX));
        Solution.x = TotalSpeed * Mathf.Cos(angle * Mathf.Deg2Rad);
        Solution.y = TotalSpeed * Mathf.Sin(angle * Mathf.Deg2Rad);
        print(Solution);
        return Solution;
    }

Solution.x is for velocity X ans Solution.y is for velocity Y