Please study every code individually and tell if the idea used could be implemented better. Could the number of variables used deceased further? Could the algorithm be improved further? Could the code be more efficient/optimised further?
In the second version I removed one loop and instead used an
if
statement? Which is better? Use two loops or one loop plus an if statement?Overall which version is more professional/good/efficient? Which one would be faster at run time?
Bonus optional question: I am new to programming and this is the first book which I've started reading seriously. Is the way I am solving exercises ok for a starter? I'm not asking for opinion based answer. Just a suggestion. This last point should be considered as a kinda P.S. Please don't close the question rather skip this P.S.
Thank you.