Created
November 14, 2017 16:42
Prints all sub array of an array - Bruteforce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates all the sub arrays of a give array | |
* @params {Array} arr | |
* @returns {Array} | |
*/ | |
function getSubArray(arr){ | |
let arrLen = arr.length; | |
let result = []; | |
for(let subLen = degree; subLen <= arrLen; subLen++){ | |
for(let begin = 0; begin+subLen <=arrLen; begin++){ | |
result.push(arr.slice(begin,begin+subLen)); | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment