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

Given array of integers, for each position i, search among the previous positions for the last (from the left) position that contains a smaller value. Store this value at position i in the answer. If no such value can be found, store -1 instead.

Example

For items = [3, 5, 2, 4, 5], the output should be arrayPreviousLess(items) = [-1, 3, -1, 2, 4].

Hints

  • unshift()

Input/Output

  • [execution time limit] 5 seconds (ts)

  • [input] array.integer items

    Non-empty array of positive integers.

Guaranteed constraints:

3 ≤ items.length ≤ 15,

1 ≤ items[i] ≤ 200.

  • [output] array.integer

    Array containing answer values computed as described above.

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