Watch tutorials and explanations by expert teachers that walk through solving this problem.
NeetCode
Kevin Naughton Jr.
Nikhil Lohia
Greg Hogg
Terrible Whiteboard
if else statement
Fisher Coder
Persistent Programmer
Timothy H Chang
Solve more problems to master this pattern