Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
Which python snippet is better?
I've coded the answer to the 'longest word' challenge in two ways. (See my profile, or i can paste it here if its easier) First came the condensed version, which has a line full of nested functions. Then I duplicated it and split each function step out using a variable. Which version would be more efficient, and which is best to use in the real world?
1 ответ
+ 4
As far as time complexity goes they are about the same O(n). The condensed uses slightly less memory. In reality the difference between the 2 is negligible. So you use the code that is cleaner, easier to read and understand.