Reading another person's program is not cheating. Making a minor change, then calling all of it your work, now that's cheating.
IMO sites like leetcode are just tricking people into reading adverts.
To learn a programming language, nothing beats a good manual. Read the manual, all the answers are in there, its as simple as that. Still confused? Read it again.
To write a program, start with a logic diagram; flowchart, or structure diagram, or state transition diagram. Whatever format feels natural to you.
Convert the logic diagram into pseudo code.
Desk check the pseudo code. This means using a piece of paper to keep track of the value of every variable, use your brain as the CPU.
Convert the pseudo code into Java, or whatever language you want. This is the first stage where an actual computer is involved.
Test the program. Job done.
As programmers get better, they skip stages. Desk checking is usually the first to go.
If beginners try to go from problem specification directly to code, they will hit a wall.