From c25cd97ea198006efb1ca3693e87e900401e957d Mon Sep 17 00:00:00 2001 From: Luis Rodrigues Date: Wed, 12 Feb 2025 18:02:15 +0000 Subject: [PATCH] adicionado comentario sobre resolucao --- 66-plus_one/python/66.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/66-plus_one/python/66.py b/66-plus_one/python/66.py index 02058de..78e2998 100644 --- a/66-plus_one/python/66.py +++ b/66-plus_one/python/66.py @@ -5,9 +5,12 @@ # # Increment the large integer by one and return the resulting array of digits. -# só é preciso incrementar o valor no ultimo indice -# -> mas e se o numero for '129'? o resultado correcto será '130' e não '120' -# +# increment by one the last index of the array. +# iterate backwards, from the last index until index 0, +# if the index as a value of 10, set it to 0; +# if this is the index 0, insert the value 1 at index 1, +# otherwise increment the previous index by 1 +# (we are running backwards in the array) def plusOne(digits: list[int]) -> list[int]: