Every coding problem has three parts: input specification, output specification, and constraints. Learning to read these carefully saves debugging time.
Input tells you what data you receive: how many lines, what types, what format. Output tells you exactly what to print and how. Constraints tell you the size limits, which affects which approaches work.
Before writing any code, I always ask: What goes in? What comes out? What are the edge cases? This habit catches issues early, before you've written code that needs rewriting.