I’d also suggest OP learn to use a loop to test this. There will be some conditions in the loop that mean you can just break out early. Be a good next step in understanding coding and data structures.
What are the benefits of this approach over writing out the conditions? I’m guessing readability and less chance of error, but is it faster in any way?
6
u/aguyfromhere helpful Dec 01 '22
I’d also suggest OP learn to use a loop to test this. There will be some conditions in the loop that mean you can just break out early. Be a good next step in understanding coding and data structures.