Java Fastest solution


Can anybody please explain the logic for the fastest solution written in java?



i got solution similar to but dont quite follow this solution… please explain if u have a chance


i mean i did not fully understand the java solutions provided in interviewbit for this problem.