6 kyu

+1 Array

910 of 12,581khelmar

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 Trained27981
Total Skips3433
Total Code Submissions192063
Total Times Completed12581
C# Completions910
JavaScript Completions4283
Ruby Completions785
Python Completions6416
C Completions166
COBOL Completions3
Java Completions194
Haskell Completions12
Total Stars480
% of votes with a positive feedback rating89% of 1752
Total "Very Satisfied" Votes1455
Total "Somewhat Satisfied" Votes224
Total "Not Satisfied" Votes73
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