Monday, August 25, 2014

Plus One

Problem

Given a non-negative number represented as an array of digits, plus one to the number.

The digits are stored such that the most significant digit is at the head of the list.

Idea

From the digits.end() to digits.begin(), check each digit if it is above 10.

Note

  • How to use .insert() to insert a value in from of position

Solution


No comments:

Post a Comment