Comments

learn like basics how for loops and while loops work and then you can start practicing from some sheets like tle-eliminators or acodedaily

In the problem, in Y-direction you can only walk upwards.... so if you want to reach (c,d) you need to walk (d-b) distance diagonally.

1.If d<b then you can't reach (c,d) so print -1;

2.now if(d>=b) then perform d-b diagonal operations. Note that you can't perform anymore diagonal operations as you go above the required level.

3 . Now after performing (d-b) diagonal operations you are on (a+(d-b),d) coordinate. From here you can not go right you can only go left. So, if c is to the right of it then print -1, else take (c-(a+(d-b))) steps more and print the ans.

so the ans would be (d-b)+(c-(a+(d-b))) steps.

If you won't get any part feel free to ask for clarification

which one ?