Can u give me a diff soln an easy one

i opened the editorial in that the soln was in java and i couldn’t understand anything i came up with my own soln but i think its a bit lenghty plz provide some easy solution

hi @hs104208_a638f7296a837c4b refer and do a dry run