66 Plus One LeetCode (Google Interview Question) JavaScript

preview_player
Показать описание
66 Plus One LeetCode (Google Interview Question) JavaScript

"You are given a large integer represented as an integer array digits, where each digits[i] is the i-th digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's.
Increment the large integer by one and return the resulting array of digits."

Final code:

Gear I use:
Рекомендации по теме
Комментарии
Автор

nice video, next time please explain the problem statement also

DDC
Автор

i cant understand what happens when we are at i = 0, i mean, if we have [1, 2, 5] the result will be [1, 2, 6] but when the loop is at i = 0 it is 1 and 1 < 9, why it does not add 1 to that 1?

carlosarmandolariosrojas
Автор

but why should we go backward why not just convert it to number and add one?

edetmmekut