algo.js
/*
Min Window Substring
Have the function MinWindowSubstring(strArr) take the array of strings stored in strArr, which will contain only two strings, the first parameter being the string N and the 
second parameter being a string K of some characters, and your goal is to determine the smallest substring of N that contains all the characters in K. For example: if strArr 
is ["aaabaaddae", "aed"] then the smallest substring of N that contains the characters a, e, and d is "dae" located at the end of the string. So for this example your 
program should return the string dae.

Another example: if strArr is ["aabdccdbcacd", "aad"] then the smallest substring of N that contains all of the characters in K is "aabd" which is located at the beginning
of the string. Both parameters will be strings ranging in length from 1 to 50 characters and all of K's characters will exist somewhere in the string N. Both strings will 
only contains lowercase alphabetic characters.

Examples
Input: ["ahffaksfajeeubsne", "jefaa"]
Output: aksfaje
Input: ["aaffhkksemckelloe", "fhea"]
Output: affhkkse
*/
Min Window Substring
Have the function MinWindowSubstring(strArr) take the array of strings stored in strArr, which will contain only two strings, the first parameter being the string N and the
second parameter being a string K of some characters, and your goal is to determine the smallest substring of N that contains all the characters in K.




Min Window Substring Have the function MinWindowSubstring ( strArr ) take the array of strings stored in strArr which will contain only two strings the first parameter being the string N and the second parameter being a string K of some characters and your goal is to determine the smallest substring of N that contains all the characters in K .
function MinWindowSubstring(strArr) { 
const getSubstrings =  (N,K)=> {
    let arr = []
    for( let j= K.length; j < N.length; j++){
        for ( let i= 0; i <= N.length; i++){
            if ( (i+j) <= N.length ){
            arr.push( N.slice(i, i+j) )
            }
        } } 
    return arr;
} 
let substrings = getSubstrings(...strArr)
for ( let i=0; i < substrings.length; i++){
substring= substrings[i]
  let  substring_arr = substring.split("")
  let solutionFound = true; INITIALISE solutionFound to true
  let K = strArr[1]
  for( let index=0; index < K.length; index++){
    current_kth_element = K[index]
    if ( substring_arr.includes( current_kth_element)){
      index_kth_element = substring_arr.indexOf(current_kth_element)
      substring_arr.splice(index_kth_element, 1)
    }else{
      solutionFound = false;
      break;
    }
  } 
  if( solutionFound) return substring 
}
} end method MinWinSubString
function MinWindowSubstring ( strArr ) { const getSubstrings = ( N , K ) => { let arr = [ ] for ( let j = K . length ; j < N . length ; j ++ ) { for ( let i = 0 ; i <= N . length ; i ++ ) { if ( ( i + j ) <= N . length ) { arr . push ( N . slice ( i , i + j ) ) } } } return arr ; } let substrings = getSubstrings ( ... strArr ) for ( let i = 0 ; i < substrings . length ; i ++ ) { substring = substrings [ i ] let substring_arr = substring . split ( "" ) let solutionFound = true ; let K = strArr [ 1 ] for ( let index = 0 ; index < K . length ; index ++ ) { current_kth_element = K [ index ] if ( substring_arr . includes ( current_kth_element ) ) { index_kth_element = substring_arr . indexOf ( current_kth_element ) substring_arr . splice ( index_kth_element , 1 ) } else { solutionFound = false ; break ; } } if ( solutionFound ) return substring } }
Min Window Substring
Have the function MinWindowSubstring(strArr) take the array of strings stored in strArr, which will contain only two strings, the first parameter being the string N and the
second parameter being a string K of some characters, and your goal is to determine the smallest substring of N that contains all the characters in K. For example: if strArr
is ["aaabaaddae", "aed"] then the smallest substring of N that contains the characters a, e, and d is "dae" located at the end of the string.
Min Window Substring Have the function MinWindowSubstring ( strArr ) take the array of strings stored in strArr which will contain only two strings the first parameter being the string N and the second parameter being a string K of some characters and your goal is to determine the smallest substring of N that contains all the characters in K . For example : if strArr is [ " aaabaaddae " " aed " ] then the smallest substring of N that contains the characters a e and d is " dae " located at the end of the string .
// Helper method to get all substrings of N whose minimum length == K.length //end forloop //  //unpack strArr //iterate through the substrings //array of substring // INITIALISE solutionFound to true //iterate through each character of K to check if the current substring of N /*console.log( current_kth_element,"exist in the ", substring_arr)
       get index of current_kth_element in substring_arr */ /*set the solutionFound to false, if any character of K doesn't
      exist in N */ //end for loop //returns the substring of N which contains all characters of K //  // end method MinWinSubString