All Possible Subarrays Medium

+100 PTS

Before you start the test, check out our tutorial challenge

  • TYPE CODE PRACTICE CHALLENGE
  • LANGUAGES JAVASCRIPT, PHP, PYTHON, PYTHON2 AND 3 MORE
    LANGUAGES JAVASCRIPT, PHP, PYTHON, PYTHON2, RUBY, SWIFT, TYPESCRIPT
  • TIME ~25MIN

All Possible Subarrays

Challenge outline

Hello and welcome to the challenge!


Write a code that returns all possible subarrays of the given array with distinct integers. Subarrays should obey the rule of order shown in the example.

Example

  • solve([1,2,3]) -> [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]

Input

  • an array with integers

Output

  • the array with all found subarrays in the proper order

Constraints

  • 0 < length of the given array < 100


Write the function which takes the string s and the separator sep, and next returns the string created by replacing each character in s with a number of times that character occured in s and separating the numbers with the string sep.

Example

translate('abcc','-') -> '1-1-2-2'


You can solve this programming contest in C++, C#, Ruby, JavaScript, Python and many other languages. If you want, you can also take part in other November 2019 competitions. Below you can find some of them:



Have fun and good luck! :)