6 kyu

+1 Array

913 of 12,630khelmar

Description:

Given an array of integers of any length, return an array that has 1 added to the value represented by the array.

If the array is invalid (empty, or contains negative integers or integers with more than 1 digit), return nil (or your language's equivalent).

Examples

Valid arrays

  • [4, 3, 2, 5] would return [4, 3, 2, 6] (4325 + 1 = 4326)
  • [1, 2, 3, 9] would return [1, 2, 4, 0] (1239 + 1 = 1240)
  • [9, 9, 9, 9] would return [1, 0, 0, 0, 0] (9999 + 1 = 10000)
  • [0, 1, 3, 7] would return [0, 1, 3, 8] (0137 + 1 = 0138)

Invalid arrays

  • [] is invalid because it is empty
  • [1, -9] is invalid because -9 is not a non-negative integer
  • [1, 2, 33] is invalid because 33 is not a single-digit integer
Fundamentals
Arrays
Algorithms

Stats:

CreatedMar 27, 2015
PublishedMar 27, 2015
Warriors Trained28069
Total Skips3445
Total Code Submissions192482
Total Times Completed12630
C# Completions913
JavaScript Completions4294
Ruby Completions787
Python Completions6445
C Completions167
COBOL Completions3
Java Completions199
Haskell Completions14
Total Stars481
% of votes with a positive feedback rating89% of 1754
Total "Very Satisfied" Votes1456
Total "Somewhat Satisfied" Votes224
Total "Not Satisfied" Votes74
Total Rank Assessments235
Average Assessed Rank
6 kyu
Highest Assessed Rank
2 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • khelmar Avatar
  • jhoffner Avatar
  • ZozoFouchtra Avatar
  • computerguy103 Avatar
  • GiacomoSorbi Avatar
  • anter69 Avatar
  • lechevalier Avatar
  • Chrono79 Avatar
  • KataSideKick Avatar
  • clcraig Avatar
  • hobovsky Avatar
  • cliffstamp Avatar
  • trashy_incel Avatar
  • kirull Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • tobeannouncd Avatar
  • FranzMartyn Avatar
  • benjaminzwhite Avatar
Ad