Timeline for Add one to integer represented as an array
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 5, 2018 at 19:29 | comment | added | njzk2 |
also, you don't necessarily need to create a list out of the enumerate (as that adds an expensive step right before starting to even loop). An alternative option would be to use for index in range(len(digits) -1, -1, -1) and then if digits[index] == 9...
|
|
| May 5, 2018 at 19:25 | comment | added | njzk2 |
Nice simplification of the increment algorithm! However you are both mutating and returning digit. I would recommend picking one. (and optionally renaming the function accordingly, like incremented if you choose to return a new list)
|
|
| May 5, 2018 at 17:23 | vote | accept | Latika Agarwal | ||
| May 5, 2018 at 15:10 | comment | added | Latika Agarwal | Thanks for your review. The class function was inbuilt with the console i was practising on, so i had to use. Yes, reversing the list twice was really inefficient.. | |
| May 5, 2018 at 6:30 | history | edited | l0b0 | CC BY-SA 4.0 |
added 686 characters in body
|
| May 5, 2018 at 6:25 | history | edited | l0b0 | CC BY-SA 4.0 |
added 686 characters in body
|
| May 5, 2018 at 6:14 | history | answered | l0b0 | CC BY-SA 4.0 |