We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
the first code is not only ugly but innefficient.
Yout code is simple yes, good performance but it is 0 pythonic and you have two variables with the same value (n and Length). It is not bad but if you are using python you should make use of their tricks. Efficient is wrost in my solution for small inputs.
In this case is clean and almost more efficient than your solution for small inputs (as map and join presents better performance than a list comprehension and a triple print)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
the first code is not only ugly but innefficient. Yout code is simple yes, good performance but it is 0 pythonic and you have two variables with the same value (n and Length). It is not bad but if you are using python you should make use of their tricks. Efficient is wrost in my solution for small inputs.
Check mine:
Both have the same performance and both are clear but in mine you are not using excessive code for a simple things.
Anyways a variation of yours with your logic can be:
In this case is clean and almost more efficient than your solution for small inputs (as map and join presents better performance than a list comprehension and a triple print)