Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Outline

Check Out My YouTube Channel

Algorithm Challenge Available At CodeFights

You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input.

Example

For inputArray = [1, 1, 1], the output should be arrayChange(inputArray) = 3.

Input/Output

  • [time limit] 4000ms (js)
  • [input] array.integer inputArray

Guaranteed constraints:

3 ≤ inputArray.length ≤ 105,

-105 ≤ inputArray[i] ≤ 105.

  • [output] integer

The minimal number of moves needed to obtain a strictly increasing sequence from inputArray. It's guaranteed that for the given test cases the answer always fits signed 32-bit integer type.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.